Let's say I have a structure, and it looks like this:
struct profile {
char firstName[15], lastName[15];
int age, phoneNo;
};
and I have a code like this
int main()
{
FILE *fPtr;
fPtr=fopen("profile.txt", "w");
printf("\n\nPlease enter your details:");
struct profile c;
printf("\n\nEnter your first name: ");
gets(c.firstName);
printf("\nEnter your last name: ");
gets(c.lastName);
printf("\nEnter your age: ");
scanf("%d", &c.age);
printf("Enter your phone number: ");
scanf("%d", &c.phoneNo);
fclose(fPtr);
return 0;
}
How do I put the data in this structure into a text file in a way that I will be able to search for specific profiles in the future? Also I'm very new to C so I'd really appreciate it if someone could explain to me if this is possible and how.