the program inputs data to an array of structures then prints out the results.. how could i create a function that would write the data to a file?
also how could i stop getting input if the user just hits return?
#include <stdio.h>
//structure to hold entries
struct entry {
char fname[15];
char lname[15];
char email[30];
};
struct entry list[20];
int x;
int main()
{
//loop to input data
for (x=0; x<20; x++)
{
printf("Enter first name: ");
scanf("%s", list[x].fname);
printf("Enter last name: ");
scanf("%s", list[x].lname);
printf("Enter Email adress: ");
scanf("%s", list[x].email);
}
printf("\n\n");
//loop to display data
for (x=0; x<20; x++)
{
printf("Name: %s %s", list[x].fname, list[x].lname);
printf("\t \tEmail: %s\n", list[x].email);
}
return(0);
}



LinkBack URL
About LinkBacks



