Home > Back-end >  Structure the input and output of the string in the array
Structure the input and output of the string in the array

Time:01-03

How to realize the function of code comments, I wrote a few times can't run, help small white day, live to be one hundred

CodePudding user response:

Should be no problem!

What's your error

CodePudding user response:

Can send the source code

Let me try

CodePudding user response:

#include
#include
Struct std_infor
{
Char * std_name;

};
Struct std_infor student [51].
Int main ()
{
Void infor_in ();
Infor_in ();

}
Void infor_in ()
{

Printf (" please enter the student's name \ n ");
The scanf (" % s ", & amp; Student [0]. Std_name);
Printf (" % s ", student [0]. Std_name);


}
//there will be abnormal to the output

CodePudding user response:

the original poster is a character of the definition of, is not a string, modify the following:
 struct std_infor 
{
Char std_name [20].
};

Struct std_infor student [51].

Int main ()
{
Void infor_in ();
Infor_in ();
for(int i=0; i<51. I++)
Printf (" % s \ n ", student [I] std_name);


return 0;
}

Void infor_in ()
{
Printf (" please enter the student's name \ n ");
for(int i=0; i<51. I++)
The scanf (" % s ", & amp; Student [I] std_name);
}

CodePudding user response:

the original well

CodePudding user response:

If using a pointer, allocating memory, and give it to use strcpy copy content
  • Related