TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Jennifer Anthony
from: Jasen Betts
date: 2004-06-02 05:50:16
subject: [C] can anyone help?

Hi Jennifer.

01-Jun-04 10:44:50, Jennifer Anthony wrote to All

 JA> From: Jennifer Anthony 

 JA> Dear Programmers, I'm a beginner in 'C'. I have been working on
 JA> files. I'm trying out small programs. The thing is if I use
 JA> fopen() function,the application which I want to read doesn't come
 JA> in front.

application?

 JA> I have to declare a temporary variable and store the
 JA> contents in the temp and then read it. The same way, if i write
 JA> into a file, I won't know if the changes have been made,unless I
 JA> open the file and check it.

You have to trust the program has made the changes etc...

#include
#include

 void errorquit(char *s,int r)
  {
   fprintf(stderr,"error: %s\n",s);
   exit(r);
   };

int main()
{
 FILE *f;
 char message[]="Hello world!";
 int r;

 f=fopen("somefile","w");

 if( !f ) errorquit ("couldn't open file to write",1);

 r=fwrite(message,sizeof(message),1,f);

 if( r < 1 )
    {
      fclose(f);
      errorquit("couldn't write to file",2);
    }
 r=fclose(f);
 if( r) errorquit("while closing file",3);

 puts("opening closing and writing the file worked");
 puts("the data is in the file, trust me.");

 return 0;
 };

 JA> Is there anyway, where I say fopen and the file pop-opens in front?

no. fopen etc don't provide a way to monitor their progress.
and if you open the file in a different application it'll probably either
interfere with the functioning of your C progam, or not show you the
changes made to the file.

 -=> Bye <=-

---
* Origin: If at first you don't succeed, the hell with it. (3:640/1042)
SEEN-BY: 633/267 270
@PATH: 640/1042 531 954 774/605 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.