well I've this little homework.
"Given a text file, create a function that search an specific ID provided by the user inside the file, If exits, print the entire profile as follow:
ID_genre_name_age_height"
So In the text file there is only one profile.
19800372_male_David_19_1.75
so, my function should print that information If I introduce the same ID.
My code which don't work so far Is this one.
void search()
{
char ced1[10],ced[10],nombre[20],sex[10],age[10],altura[5];
FILE *in;
in=fopen("c:\\ex.txt","r");
clrscr();
printf("Enter ID: ");
gets (ced1);
do{
fscanf(in,"%.0f %s %s %d %.2f",ced,sex,nombre,edad,altura);
if (strcmpi(ced,ced1)==0)
{
printf("Cedula:%.0f\n",ced);
printf("Sexo:%s\n",sex);
printf("Nombre:%s\n",nombre);
printf("Edad:%d\n",edad);
printf("altura:%.2f\n",altura);
}
}
while(!feof(in));
fclose(in);
getch();
}