From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linserver.romuald.net.eu.org ([63.228.150.209]) by speech.braille.uwo.ca with esmtp (Exim 3.36 #1 (Debian)) id 1FedYW-0004wW-00 for ; Fri, 12 May 2006 15:44:08 -0400 Received: (qmail 19832 invoked by uid 1000); 12 May 2006 12:43:37 -0700 Date: Fri, 12 May 2006 12:43:37 -0700 From: Gregory Nowak To: Tyler Littlefield , "Speakup is a screen review system for Linux." Subject: Re: can someone look at this? sorry if its o-t Message-ID: <20060512194337.GA18915@localhost.localdomain> References: <002801c675ec$1f8d1870$6501a8c0@grandmasfury> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; x-action=pgp-signed Content-Disposition: inline In-Reply-To: <002801c675ec$1f8d1870$6501a8c0@grandmasfury> X-PGP-Key: http://www.romuald.net.eu.org/pubkey.asc User-Agent: Mutt/1.5.11+cvs20060403 X-BeenThere: speakup@braille.uwo.ca X-Mailman-Version: 2.1.8rc1 Precedence: list Reply-To: "Speakup is a screen review system for Linux." List-Id: "Speakup is a screen review system for Linux." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 May 2006 19:44:09 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I don't see any reference to fdata in your code, unless it is defined somewhere in the header files you include, something I haven't checked into. I've tried compiling your code anyway, and found the following: First, the line that says dfile=fopen("darg", "w"); has the compiler telling me that dfile is undefined. I'm guessing that you wanted to write: FILE *dfile=fopen("darg", "w"); in which case, you should have declared dfile at the top of your function, following good c/c++ programming practices. Also, when using fopen, it's a really good idea to check that your pointer is actually assigned to a open file after you open it. The next error gcc returns is 4 lines later, saying that dfile isn't a const char*: printf(dfile, usr); I have no clue what you're trying to do here. If you meant to use dfile as a pointer to an open file, I don't see why you'd want to print it out to stdout. I didn't try to fix this farther. Also, I'm wondering why you're including c++ header files, as if you're fixing to write c++ code, but then write your code entirely in c? If you're going to do that, then you might as well include fstream, and use ifstream and ofstream for file i/o, which in my humble opinion is a heck simpler then using fopen. Greg On Fri, May 12, 2006 at 11:47:17AM -0600, Tyler Littlefield wrote: > Hay list, > I know this is off-topic, but it says fdata is out of scope, can someone look at it and tell me what is going on? > Thanks, > #include > #include > #include > #include > #include > #include > #include > struct data{ > int alt; > char *data; > char *usern; > }; > using namespace std; > int main() > { > openlog("Dataplus client", LOG_PID, 0); > switch ( fork() ) { > case -1: > syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_ERR), "There was an error starting the dataplus client."); > return 1; > case 0: > break; > return 0; > } > if ( setsid() < 0 ) > { > syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_ERR), "There was an error starting the dataplus client."); > return 2; > } > syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_NOTICE), "Dataplus client ready."); > data usr; > usr.alt=322; > usr.data="linux"; > usr.usern="tyler/root"; > dfile=fopen("darg", "w"); > int i; > for (i = 0; i++; i < 12) > { > printf(dfile, usr); > fflush(dfile); > } > fclose(dfile); > return 0; > } > _______________________________________________ > Speakup mailing list > Speakup@braille.uwo.ca > http://speech.braille.uwo.ca/mailman/listinfo/speakup - -- web site: http://www.romuald.net.eu.org gpg public key: http://www.romuald.net.eu.org/pubkey.asc skype: gregn1 (authorization required, add me to your contacts list first) - -- Free domains: http://www.eu.org/ or mail dns-manager@EU.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQFEZOVp7s9z/XlyUyARAh9CAJ9gOc46dlTB6Vouc1d/VfHpp0PQBwCfZhTa 0uvKvuFwOazS2T6NGgqZ964= =zlEo -----END PGP SIGNATURE-----