the problem is to read from a file(the files are read in command line, linux) a character, then a tic tac toe matrix. then i want to return what i read (just a small test). i got segmentation fault. from what i've searched, the problem was a new line, so i consumed it with dummy. the same answer came. i checked if the files are opened correctly. i'd appreciate some help, thank you.
o
- x o
o x o
- - x
int main(int argc, char *argv[])
{
FILE *src, *dest;
int i,j;
char s[2];
char* dummy;
char* m[3][3];
src=fopen(argv[1],"r");
dest=fopen(argv[2],"w");
fscanf(src,"%s",s);
fscanf(src,"%s",dummy);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
fscanf(src,"%s",m[i][j]);
}
fscanf(src,"%s",dummy);
}
for(i=0;i<3;i++)
for(j=0;j<3;j++)
fprintf(dest,"%s",m[i][j]);
fclose(src);
fclose(dest);
return 0;
}