My input file contain:
1
2
3
4
5
6
why is it not reading properly, i tried implementing fget and fread but failed even after reading dani web and other tutorials.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
typedef struct{
char lname[20];
char fname[20];
int salary;
}employee;
const int max = 2;
int main (){
int count = 0;
int j = 0;
employee emp;
FILE *input;
input = fopen("input.txt","r");
while (!feof(input) ){
fscanf (input,"%s\n ",emp.fname);
fscanf (input," %s \n",emp.lname);
fscanf (input," %d \n",&emp.salary);
}
do{
printf ("FNAME: %s \n ",emp.fname);
printf ("LNAME: %s \n",emp.lname);
printf ("Salary: %d \n",&emp.salary);
count++;
}while (count< max);
getch ();
return 0;}