Jeff Weisberg on Thu, 20 Jun 2002 02:40:20 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] this code crashes [OT]



| Sorry for the non-c coders. Don't want to bore you.

how could C ever be boring?


| This code will crash:
| 
| bytes_read = fread(buffer, 1, MAX_BUF, source);
|   /* second arg could be whatever you like; 1 == sizeof(char) in my world
| */
| while(bytes_read) {
| 	  fwrite(buffer, 1, bytes_read, dest);
| }


it crashes because you did not declare any of your variables
and did not attempt to open any files.
(or more likely, you did, but aren't showing us, leaving us
wondering and feeling unfulfilled).

this snippet does not have enough context. I'd want to know how the
variables are declared, and what their values are.

show more.

also, this code will (were it working) not do anything interesting.

you are reading one chunk of data, if the fread succeeds, your loop
writes the same block over and over and over and over ...


| I'm wondering why, I'm guessing that the 4th arg in bytes_read should be
| pointer. I'm going to test that now.
| 
| I really appreciate all the help, espcially from Gabriel. This is going to
| work, just a little more tweaking.

oh, sorry. I'm not G. press delete.


	--jeff



______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug