//stores and retrieves data for two secret asgents
#include%26lt;stdio.h%26gt;
void main ()
{
struct personnel {
char name [30];
int agnumb; int agent;
};
struct personnel agent1;
struct personnel agent2;
char numstr[81];
printf("\nagent 1.)\nEnter name:");
printf("Enter agent number (3 digits): ");
gets(numstr);
agent1.agnumb=atoi(numstr);
gets(agent2.name);
printf("Enter agent number (3 digits);");
gets(numstr);
agent2.agnumb=atoi(numstr);
printf("\nList of agents:\n);
printf(Agent number: %03d\n", agent1.agnumb);
printf("Name: %s\n", agent2.name);
printf(Agent number: %3d \n", agent2.agnumb);
}
please help correct the program, there after, from the same program, use arrays so that the structure can store and retrieve data on 20 agents.
C++ (structures)what is the matter with the following program?
struct personnel %26lt;------what's this, and why are some of your declarations in curly backets?
{
char name [30];
int agnumb; int agent;
};
Also, where are the scanf statements for input?
your best bet, as far as I know, is a 20 time for loop. Inside, the code to scan in all the data, and a counter to send it to the propper location in the array.
Hope that helped. Then again, I have a 5 month experience from school on C, lol. Good luck.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment