Home > Software engineering >  New super foundation exe appear a small program to stop working for the great spirit show where is w
New super foundation exe appear a small program to stop working for the great spirit show where is w

Time:09-27

The code below
 # include & lt; Iostream> 
#include
using namespace std;
Void main ()
{
Char * ID [6]={" 10 ", "11", "12", "13", 14 ", "15"},
* telephonenumber [6]={" 6311 ", "5232", "2968", "6688", "8919", "3828"},
* name [6]={" Ming "and" zi ", "sui", "bian", "da" and "DE"};
Int I, order;
Char * id;
cout<" Please enter the student id: ";
Cin> Id;
for(i=0; i<6; I++)
If (STRCMP (id, id [I])==0)
{order=I;
break;
}
cout<" Name: "& lt; cout<" Phone number: "& lt; }


Has just started to learn, this is a job, enter student id and then output the corresponding name and phone number, array pointer what are still a little not too clear, then you really will not change ah QAQ hope I can help it right

CodePudding user response:

Oh what name is different in the screenshot program has privacy...

CodePudding user response:

Char * id;
cout<" Please enter the student id: ";
Cin> Id;

Id wild pointer

Char id [128]={0};

CodePudding user response:

Thank you me have a try on the second floor ps. Last night may be silly to enter student id name, I always loses.

CodePudding user response:

Your logic also incomplete, if the input to, order no initialization, may also lead to cross-border melt
 
#include
#include
using namespace std;
Void main ()
{
Char * ID [6]={" 10 ", "11", "12", "13", 14 ", "15"},
* telephonenumber [6]={" 6311 ", "5232", "2968", "6688", "8919", "3828"},
* name [6]={" Ming "and" zi ", "sui", "bian", "da" and "DE"};
Int I, order=1;
Char id [128]={0};
cout<" Please enter the student id: ";
Cin> Id;
for(i=0; i<6; I++)
{
If (STRCMP (id, id [I])==0)
{
The order=I;
break;
}
}
If (the order & gt;=0)
{
cout<" Name: "& lt; cout<" Phone number: "& lt; }
The else
{
Cout & lt; <"Didn't find" & lt; }
}

CodePudding user response:

Ok had been changed

CodePudding user response:

Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand when double click on the next line, until we can read ,

CodePudding user response:

Char * id; -- "char id [XXXX]={0};
  • Related