yeah i suppose, just not sure this might work, for the binary file that's another program, i'll create so it just opens the binary file to display the information.
Code:
#include<stdlib.h>
#include<stdio.h>
struct student
{
char name[200];
float marks;
};
int main()
{
FILE * txtFile;
struct student tempStudent;
// File pointer to binary file
FILE * binFile;
int searchNum;
char s[200];
if ((txtFile = fopen("input.txt", "r")) == NULL)
{
printf("Can not open file input.txt\n");
}
else
{
binFile = fopen("binary_file.txt", "wb");
}
while (fscanf(txtFile,"%s %f", tempStudent.name, &(tempStudent.marks)) == 2)
{
// write code that stores the structure tempStudent into the binary file
}
printf("Please enter the student you want to search for\n");
printf("For example if you want the first student type 1\n");
scanf("%d", &searchNum);
fseek(binFile, searchNum*sizeof(tempStudent), SEEK_SET);
fread(name, sizeof(tempStudent), 200, binFile);
fwrite(name, sizeof(tempStudent), 200, binFile);
printf("The student name retreived is: %s\n", tempStudent.name);
printf("The student mark retreived is: %.2f\n", tempStudent.marks);
fclose(binFile);
fclose(txtFile);
return 0;
}