Hi guys, I am developing code on the TS7400 running debian, and I have
encountered a problem with writing to files. I am new to writing
software for debian, so please bear with me.
my program exits after printing a segmentation fault... here is my
code, its basically just a hello world to a file.
int main (){
FILE * f1 = (FILE*)(open("test.txt", O_RDWR|O_CREAT, S_IRUSR |
S_IWUSR | S_IRGRP | S_IRWXO));
if (f1!=NULL){
printf("\nfile test.txt created\n");
fprintf(f1,"Hi... im the file contents");
fclose (f1);
} else {
printf("\nfile failed to open\n");
fclose (f1);
}
return 0;
}
when I exicute the program it prints that the file is created, so I
know I am not trying to write to a NULL pointer. Just after that the
segmentation fault occurs. test.txt exists but is empty.
Please tell me why this is happening, and what I can do to resolve it
Thanks,
David
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|