fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. /* strindex which returns rightmost occurance */
  13.  
  14. #include<stdio.h>
  15.  
  16. int mstrindex(char source[],char searchfor[]);
  17.  
  18. int main(void)
  19. {
  20. char line[] = "abcdedfabcde";
  21. char pattern[] = "abc";
  22.  
  23. int found;
  24.  
  25. /* It should match the a the 7th position. */
  26.  
  27. found = mstrindex(line, pattern);
  28.  
  29. printf("Found the right index: %d\n", found);
  30.  
  31. }
  32.  
  33. int mstrindex(char s[],char t[])
  34. {
  35. int i,j,k, result;
  36.  
  37. result = -1;
  38.  
  39. for(i=0;s[i]!='\0';i++)
  40. {
  41. for(j=i,k=0;t[k]!='\0' && s[j]==t[k];j++,k++)
  42. ;
  43. if(k>0 && t[k] == '\0')
  44. result = i;
  45. }
  46. return result;
  47. }
  48. }
  49. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:14: error: illegal character: '#'
#include<stdio.h>
^
Main.java:14: error: not a statement
#include<stdio.h>
        ^
Main.java:14: error: ';' expected
#include<stdio.h>
                 ^
Main.java:16: error: ';' expected
int mstrindex(char source[],char searchfor[]);
             ^
Main.java:16: error: <identifier> expected
int mstrindex(char source[],char searchfor[]);
                            ^
Main.java:16: error: ';' expected
int mstrindex(char source[],char searchfor[]);
                                            ^
Main.java:18: error: ';' expected
int main(void)
        ^
Main.java:18: error: illegal start of expression
int main(void)
         ^
Main.java:18: error: ';' expected
int main(void)
             ^
Main.java:33: error: ';' expected
int mstrindex(char s[],char t[])
             ^
Main.java:33: error: <identifier> expected
int mstrindex(char s[],char t[])
                       ^
Main.java:33: error: ';' expected
int mstrindex(char s[],char t[])
                               ^
12 errors
stdout
Standard output is empty