I'm doing a C program where the user is asked to enter an employee number. I know how to make the program ask again if the number doesn't exist. However, I don't know how to have the program check it from a *.txt file like this.
EMP10-1234,smith_john,2
EMP08-0321,kent_brenda,1
EMP10-0501,delcambre_kory,3
EMP11-0112,pregeant_mark,3
Upon entering a number, the following would be presented:
Employee No.: 10-1234
Smith, John
Manager
Manager is printed because of the number 2.
This is my code so far.
#include<stdio.h>
#include <stdlib.h>
#include<conio.h>
#include<ctype.h>
#include<string.h>
char ch
FILE *f;
int main(){
clrscr();
CreateTimeFile();
ReadEmpFile();
getch();
}
CreateTimeFile(){
f = fopen("time.txt","w");
fclose(f);
}
ReadEmpFile(){
f = fopen("Employee.txt","r");
while( ( ch = fgetc(f) ) != EOF )
printf("%c",ch);
SplitLines
fclose(f);
}
SplitLines(){
}
/*
Create time.txt
Read Employee.txt
Split lines (4)
Split each lines (EmpNo, EmpName, EmpPos)
Do Program Requirement (Ask Employee Number)
Display Program Requirements
Get TimeIn and TimeOut Each Day
Append to time.txt all the time-in and time-out
Convert TimeIn and TimeOut Each Day
Compute for total time and Salary
Append Salary to time.txt
Display Program Requirement
*/
What I don't know is how to "split the lines". Could anybody tell me? The bottom lines are the hints provdied by my teacher.