Mail Archives: djgpp/2000/02/22/13:15:40
Now I know why f == 0: It cannot be opened: perror prints PERMISSION DINIED!
Thanks!!
Waldemar Schultz schrieb in Nachricht <38B2BD38 DOT 4134FA71 AT ma DOT tum DOT de>...
>Florian X schrieb:
>>
>> Hi!
>>
>> I use this in my program:
>>
>> char *string= "Hello world";
>> FILE * f = fopen("file.txt", "a");
>> fprintf(f, "%-128s", string);
>>
>> // ftell(f);
>>
>> fclose(f);
>>
>> But it doesn't write the text to the file, if i use ftell(...) after
>> fopen(...), ftell(...) returns -1 (error);
>>
>> ftell
>
>I tried this with gcc and it works as expected.
>
>=======================================
>#include <stdio.h>
>
>int main(void)
>{
>char *string= "Hello world";
>FILE * f = fopen("file.txt", "a");
>
> if(!f)
> {
> perror("file.txt");
> return 1;
> }
> fprintf(f, "%-128s\n", string);
>
> printf("%ld\n",ftell(f));
>
> fclose(f);
>
> return 0;
>}
>=======================================
>Try this standalone. May be you currupted your system elsewhere
>and now you stare at the wrong place. hope that helps.
- Raw text -