--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Please help me...
Sir/Ma'am I think I got this one working using this code but I have one problem:
this is the code:

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
FILE *fp;
char code[80],code2[80], ename[80];
int elevel;
clrscr();
if((fp = fopen("samplete.txt","r"))==NULL) {
printf("cannot open file.\n");
}

printf("Enter ID: ");
gets(code2);

 while(!feof(fp)) {

    fscanf(fp,"%s %s %d",code,ename,&elevel);

        if(strcmp(code2,code)) {
           printf("%s %s %d",code,ename,elevel);
           break;
           }
 }
fclose(fp);
getch();
}

The problem is it only display the first record or first line of text in my notepad file

lets say when I Enter the ID: ST-0002

it only display the first record or the first line of text file which is: ST-0001, Eddie_VanHalen, 1

it should be: ST-0002, James_Hatfield, 2

Please help me... thanks in advanced

...but I have one problem

No, you have many problems.
1) Using bold, underline, red text, lines of hyphens to make your post look cute. It's unnecessary and distracting. By the way, you forgot to use italics.
2) Your formatting is bad -- see this
3) void main() -- main() is never a void, see this
4) clrscr(); -- useless and annoying for the user, and hasn;t been available in compilers since 1990
5)

if((fp = fopen("samplete.txt","r"))==NULL) {
printf("cannot open file.\n");
}

What happens if it can't open the file? You continue anyway
6) gets(code2); -- extremely dangerous, see this
7) while(!feof(fp)) -- error prone loop, see this

You might want to learn from a better source. Your current source seems to be older than the hills, and is teaching very bad techniques.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.