char *file1charbuf=(char*)malloc(sizeof(char));
char *file2charbuf=(char*)malloc(sizeof(char));
in loop until EOF I read char into *file1charbuf
and *file2charbuf
and then compare.
...
check=read(file1, file1charbuf, 1);
check2=read(file2, file2charbuf, 1);
if (*file1charbuf!=*file2charbuf){
printf("differ: char %i, line %i\n",charpos,linepos);
exit(1);
}
....
compare works fine but i want to keep pointer in stack,not in heap. Also malloc is C lib function.
char *file1charbuf[1]; //1 element array of char
char *file2charbuf[1];
with that comparing doesnt work right
...
if (file1charbuf[0]!=file2charbuf[0]){
printf("differ: char %i, line %i\n",charpos,linepos);
exit(1);
}
...
and the second question. Is it necessary close(file1)
if exit(1)
found?
- I should use ONLY sys calls,not lib functions.