Greetings all,
Any idea on the following code? This code is out of a beginners 'C' book; at first I got the error message, then I fixed the file location address and the error message went away. Now when I check the file for content, there is nothing.
Note: I'm using Borland Turbo C++ Ver. 3.0
Code:
#include <stdio.h>
#include <stdlib.h>
FILE *fptr;
main()
{
int age = 22; /* Simple variables to write */
float salary = 19670.50;
fptr = fopen("C:\WINDOWS\DESKTOP\BT\MYDATA.TXT", "w"); /* Opens for output */
if (fptr == 0)
{ printf("An error occurred while opening the file.\n");
exit (1);
}
fprintf(fptr, "Here is some stuff:\n");
fprintf(fptr, "I am %d years old.\n", age);
fprintf(fptr, "I make $%.2f dolLars every three months!\n", salary);
fclose(fptr); /* Always close your files */
return 0;
}
Eating the elephant one byte at a time.