From: Waldemar Schultz Newsgroups: comp.os.msdos.djgpp Subject: Re: File Date: Tue, 22 Feb 2000 17:45:44 +0100 Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany) Lines: 45 Message-ID: <38B2BD38.4134FA71@ma.tum.de> References: <38b2ab5f$0$83570 AT SSP1NO17 DOT highway DOT telekom DOT at> NNTP-Posting-Host: pcritter10.mathematik.tu-muenchen.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: wsc10.lrz-muenchen.de 951237944 26900 131.159.69.74 (22 Feb 2000 16:45:44 GMT) X-Complaints-To: news AT lrz-muenchen DOT de NNTP-Posting-Date: 22 Feb 2000 16:45:44 GMT X-Mailer: Mozilla 4.7 [de] (Win98; I) X-Accept-Language: de,en,en-US Xcanpos: shelf.2/200003072101!0005415693 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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 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.