Home > Back-end >  Why can't I input student information input will show how I input the information of the save s
Why can't I input student information input will show how I input the information of the save s

Time:12-13

#include
#include
Int stu=0;
Void the add ()
{
Char name [10], sex [10].
int age;
Long int tel num;
int i;
for(i=1; i<=5; I++)
{
Printf (" please enter the first % d student information: \ n ", I);
Printf (" please enter the student student number: ");
The scanf (" % ld ", & amp; Num);
If (num==0)
{
break;
}
Printf (" please enter the student's name: ");
The scanf (" % s ", name);
//fflush (stdin);
Printf (" please enter the student age: ");
The scanf (" % d ", & amp; The age);
//fflush (stdin);
Printf (" please enter the student gender: ");
The scanf (" % s ", sex);
Printf (" please enter the student number: ");
The scanf (" % ld ", & amp; Tel);
printf("\n");
}
}
Void the modify ()
{
Int stu.
Printf (" please input to modify the student's name: ");
The scanf (" % d ", & amp; Stu);
}

Void menu ()
{
Printf (" \ n \ n \ n \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" * * * * * * * * * * * * the student information management system * * * * * * * * * * * * \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" * * * * * * * * * * * * system function menu * * * * * * * * * * * * \ n ");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Printf (" * * * 0. Quit the student system * * * 1. Add student information * * * \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n \ n ");
Printf (" * * * 2. Modify the students information * * * 3. Delete student information * * * \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n \ n ");
Printf (" * * * 4. Query student information * * * 5. Information on students sort \ n * * * ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n \ n ");
Printf (" * * * 6. Show all student information * * * 7. Save the current student information * * * \ n ");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - \ n ");
Printf (" please select menu number (0 to 7) : ");
}
Void keyDown ()
{

int choice=0;
The scanf (" % d ", & amp; Choice);
The switch (choice)
{
Case 0:
Printf (" exit the student system! \n");
system("pause");
system("cls");//clear screen
break;
Case 1:
Printf (" information add students \ n ");
The add ();
break;

Case 2:
Printf (" modify the students information \ n ");
The modify ();
break;
Case 3:
Printf (" delete student information \ n ");
break;
Case 4:
Printf (" query student information \ n ");
break;
Case 5:
Printf (" \ n sorting student information ");
break;
Case 6:
Printf (" information shows all students \ n ");
break;
Case 7:
Printf (" to save the current student information \ n ");
break;
Default:
Printf (" choose wrong, please input again \ n ");
system("pause");
break;
}
}

Int main ()
{
While (1)
{
The menu ();
KeyDown ();
system("pause");
system("cls");
}
system("pause");
return 0;
}



CodePudding user response:

 void the add () 
{
Char name [10], sex [10].
int age;
Long int tel num;
int i;
for(i=1; i<=5; I++)
{
Printf (" please enter the first % d student information: \ n ", I);
Printf (" please enter the student student number: ");
The scanf (" % ld ", & amp; Num);
If (num==0)
{
break;
}
Printf (" please enter the student's name: ");
The scanf (" % s ", name);
//fflush (stdin);
Printf (" please enter the student age: ");
The scanf (" % d ", & amp; The age);
//fflush (stdin);
Printf (" please enter the student gender: ");
The scanf (" % s ", sex);
Printf (" please enter the student number: ");
The scanf (" % ld ", & amp; Tel);
printf("\n");
}
}

Cycle 5 times, but they are all cover the current input with one input and no keep each input,

Make a bad example, bear to break off the corn, finally get the last corn; If make it the bag, it can keep every corn,

This bag is an array or apply for five students information of memory;

CodePudding user response:

Ok thank you what about specific how to operate a beginner to guide
  • Related