Home > Back-end >  The novice consult
The novice consult

Time:10-07

#include
#include
# define M 3
# define N 30
Void main ()
{
Char * p [M];
int i;
Void getChar (char * p [], int n);
GetChar (p, M);
Printf (" input string: \ n ");
for(i=0; i{
Printf (" % s \ n ", * (p + I));
}
printf("\n");
system("pause");
}

void getChar (char * p [], int n)
//input from a terminal n string
{
Int I;
for(i=0; i{
The scanf (" % s ", * (p + I));
}
}



When the input string is displayed
{file. Exe of 0 x771fde8f (msvcr100d. DLL) in untreated exception: 0 xc0000005: access violation occurred while writing position 0 XCCCCCCCC}
Trouble great god to help me take a look at what went wrong, novice for advice,,,

CodePudding user response:

 void main () 
{
Char * p [M];
int i;
Void getChar (char * p [], int n);
GetChar (p, M);
Printf (" input string: \ n ");

For (I=0; I & lt; M; I++)
{
Printf (" % s \ n ", (p + I)); Pointer to//
}

printf("\n");
system("pause");
}

Void getChar (char * p [], int n)//input from a terminal n string
{
int i;
For (I=0; I & lt; n; I++)
{
The scanf (" % s ", (p + I)); Pointer to//
}
}

CodePudding user response:

String with a pointer, char * if * * became a char single characters
  • Related