I'm new to structures, our instructor haven't discussed it yet...
Im trying to make a program that will ask the user 5 "fruits".
Ex.
The user input:
Mango
Apple
Mango
Grapes
Grapes
Output:
Fruits entered: 2 Mango
1 Apple
2 Grapes
I've trying to see some tutorials but i can't find anything like this...
Can anyone help me? I would appreciate it...
#include <stdio.h>
#include <string.h>
struct fruit{
char diet[20];
int number;
}name1,name2;
int main ()
{
printf("Enter a fruit: ");
scanf("%s",&name1.diet);
printf("Enter a fruit: ");
scanf("%s",&name2.diet);
//.....
printf("Fruits entered: %s",name2.diet);
getchar();
getchar();
return 0;
}