hello guys im having a problem.. i have a text file name employee.txt and it is the construction of the text file..
Juan Dela cruz,A02-0001,1
C plusplus,A02-0002,2
Pedro Dela Cruz,A02-0003,3
now i have done coding when the user input the emp id and then it will search through the file..when i search A02-0001
it only outputs
A02-0001,1 (no Juan Dela Cruz)
and also when i search the A02-0002 nothing happens..
by the way here's my code.
Turbo c++ Code:
#include <conio.h> #include <stdio.h> #include <string.h> main(){ clrscr(); FILE *rf; char getLine[50]; char searchWord[50]; char *rWord; printf("Enter emp ID: "); scanf("%s",getLine); rf = fopen("C:\\employee.txt","r"); fgets(searchWord,50,rf); if (!feof(rf)){ rWord = strstr(searchWord,getLine); printf (rWord); } getch(); return 0; }
i use the turbo c++ compiler..
thanks in advance




Reply With Quote