hi im trying to retreive data from a file using a function call but it doesnt return the data back to the main(). ive tried changing some varriables to pointers and vice versa but the moment of return gives me what the input was, not the info i want to be returned,im a bit lost at the moment can anyone help? please?
Code:
char searcher(char *ItemDat);
char retdat[250];
char ItemId[250];
char FTextdata[250];
FILE*ReadDatFP;
main ()
{
printf("Enter Item Id: ");
scanf("%s",&ItemId);
searcher(ItemId);
printf("\n\nMain Output:\n%s\n",ItemId);
system("pause");
}
char searcher(char *ItemDat)
{
if((ReadDatFP=fopen("TEST.txt","r"))==NULL)
{
printf("File could not be opened\n");
system("pause");
}
else
{
printf("File could be opened\n");
system("pause");
do
{
fscanf(ReadDatFP,"%s",FTextdata)!=EOF;
}
while(strcmp(ItemDat,FTextdata)!=0);
}
fscanf(ReadDatFP,"%s",retdat)!=EOF;
printf("\nFunction output:\n%s\n",retdat);
system("pause");
fclose(ReadDatFP);
return *retdat;
}
The system pauses were for direction diagnosis in my program and are not intended as part of the real program, Thanks for any help on this it is my first post.