[plug] C, bad syntax etc.

Carl Gherardi C.Gherardi at curtin.edu.au
Mon Nov 18 17:31:27 WST 2002



> 
> G'day all! I'm having quite  a few probs with file i/o here, 
> would someone 
> be able to troubleshoot this code?
> 
> 
>   do
>     {
>     fptr = (fopen  ("num.dat", "wa+"));
>     fprintf(fptr, " %d", number[count]);
>     //flcose (fptr);

fclose I assume no thte typo above - methinks you shouldn't be reopening the
file each time around the loop either. Stick the file open + error checking
outside the loop.

You should only need one of the args to fopen either w or a not both.

fptr = fopen("num.dat", "w+");

do
{
	fprintf(fptr, " %d", number[count]);
	count++;
}while (count < 9);
return 0;



More information about the plug mailing list