Hi everyone again me again I have lots of questions...
I have a program which reads something into a txt file like notepad. But I need to read into a dat file. Here is my code
#include <stdlib.h>
#include <stdio.h>
main()
{
int employeeNumber;
char name[30];
char engineeringDicipline[40];
int yearOfBirth;
FILE *cfPtr;
if((cfPtr = fopen("employee.txt","r")) == NULL)
printf("File could not be opened\n");
else {
printf("%-20s%-13s%-20s%10s\n", "EmployeeNumber", "Name","EngineeringDicipline", "YearOfBirth");
printf("________________________________________________________________\n");
fscanf(cfPtr, "%d%s%s%d", &employeeNumber,name,engineeringDicipline,&yearOfBirth);
while (!feof(cfPtr))
if(employeeNumber!=0){
printf("%-20d%10s %-20s%7.2d\n",employeeNumber,name,engineeringDicipline,yearOfBirth);
fscanf(cfPtr, "%d%s%s%d", &employeeNumber,name,engineeringDicipline,&yearOfBirth);}
system("PAUSE");
fclose(cfPtr);
}
system("PAUSE");
return 0;
}