Re: program bug



Bill Cunningham wrote:
"Robert Gamble" <rgamble99@xxxxxxxxx> wrote in message

a is not initialized, referencing its value invokes undefined
behavior.

a=fgetc(ifp);
fputc(a,ofp);

In the beginning a was declared. Is it not enough in this case to
simply declare an int? Or should I have done this int a=0; at the
beginning of the program?

You are using it before loading it. You want:

while (EOF != (a = fgetc(ifp))) fputc(a, ofp);

Note the use of blanks. As I recall there are other errors also.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.


** Posted from http://www.teranews.com **
.



Relevant Pages