Skip to content

Instantly share code, notes, and snippets.

@paranoidxc
Created May 19, 2014 06:28
Show Gist options
  • Save paranoidxc/39b6b6e8daea302369e6 to your computer and use it in GitHub Desktop.
Save paranoidxc/39b6b6e8daea302369e6 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define N 20
main( int argc, char *argv[] ) {
int i, j, t;
char a[N], *p = argv[1];
for ( i = 0; i < N-1; a[i] = t, i++ ) {
if ( (t=getchar()) == EOF ) {
break;
}
}
a[i] = 0; //a[i] = '\0';
//printf("%s\n",p);
//printf("%s\n",a);
for ( i = 0; a[i] != 0; i++ ) {
for ( j = 0; p[j] != 0; j ++ ) {
if ( a[i+j] != p[j] ) {
break;
}
}
if ( p[j] == 0 ) {
printf("%d", i);
}
}
printf("\n");
system("pause");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment