I am new to c programming. I am working of a text file with the following format
1 2009 james smith 2 18
2 2010 bob davies 5 18
3 2010 Allan Thomson 15 26
4 2010 Brad Haye 15 26
What I want to do is read each line and print to the console in meaningful way like
James smith made his debut in 2009 and earns 2m a year. He has earned 18m over his lifetime with an average of xyzM a year
Then
Highest Earner: ?
Average Earning: ?
total players:
This is what I have so far:
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <stdlib.h>
typedef char *string;
int main() {
int i = 0, line = 5;
char ch[100];
string array[4];
FILE *myfile;
myfile = fopen("C:/Data/Players.txt","r");
if (myfile== NULL)
{
printf("File Does Not Exist \n");
return 1;
}
while(line--)
{
fscanf(myfile,"%s",&ch[i]);
printf("\n%s", &ch[i]);
array[0] = array[i];
i++;
if(i=5)
{
printf("Yes");
}
}
fclose(myfile);
return 0;
}