Hi all,
I'm using C to read file contain array of string. The file contain this array:
Code:
{"Robin Van Persie","Alan Shearer","Bacary Sagna","Juergen Klinsmann"}
I want to compare those array of string with char array. Here's what I've done so far:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
FILE *fp;
char name[] = "Alan Shearer";
int i;
char *content[4];
/* read the values */
if((fp=fopen("test.txt", "r"))==NULL) {
printf("Cannot open file.\n");
}
fgets(*content,sizeof(*content),fp);
for(i=0;i<sizeof(content);i++) {
if(strcmp(content[i],name)==0) {
printf("%s found",name);
}
}
return 0;
}
when I run compiled program it shows error message:
2 [main] myfile 2108 exception::handle: Exception: STATUS_ACCESS_VIOLATION 1182 [main] myfile 2108 open_stackdumpfile: Dumping stact trace to myfile.exe.stackdump
Please help me, I'm new bie in C programming..
Regards,
Didin