|
|
back to boardAccess violation on #5 My program crashes on #5. My input func ignoring EOF symbol and I using my own (because I'm a starter ;)) search in strings (that's below). I can't find test that crash my prog. Can you give me hint what's wrong or give test? //----------------------------- int srch(char *str, char *cond) { char *blk; int i, j; blk = (char*)malloc((strlen(cond)+1)*sizeof(char)); blk[strlen(cond)] = '\0'; for(i = 0; i < strlen(str)-strlen(cond)+1; i++) { for(j = 0; j < strlen(cond); j++) blk[j] = str[i+j]; if(!strcmp(blk,cond)) return i+1; } return 0; } void parse(char **e, int Ecount, char **t, int Tcount) { int i, j, pos; for(i = 0; i < Tcount; i++) for(j = 0; j < Ecount; j++) if(strlen(e[j]) && strlen(t[i]) && (pos = srch(t[i],e[j]))) { printf("%d %d",i+1,pos); return; } puts("Passed"); } |
|
|