Home > Back-end >  The structure characters of the members does not assignment problem
The structure characters of the members does not assignment problem

Time:01-06

 # include & lt; stdio.h> 
# include & lt; Stdlib. H>
Struct c_node {
char data; };
Int main ()
{
Struct c_node * head=(c_node *) malloc (sizeof (* head));
The head - & gt; Data='https://bbs.csdn.net/topics/g'.
return 0;
}

When I debug this simple program, to 8 rows cannot continue to go down, is this why? Hope to have a great god answer!

CodePudding user response:

Struct c_node * head=(c_node *) malloc (sizeof (* head));
Change
Struct c_node * head=(c_node *) malloc (sizeof (c_node));

CodePudding user response:

Struct c_node * head=(struct c_node *) malloc (sizeof (struct c_node));

CodePudding user response:

How to not bottom go to, do nothing, he went home
 # include & lt; stdio.h> 
# include & lt; Stdlib. H>

Struct c_node {
char data;
};


Int main ()
{
Struct c_node * head=(c_node *) malloc (sizeof (* head));
The head - & gt; Data='https://bbs.csdn.net/topics/g'.

Printf (" % c \ n ", the head - & gt; The data);

return 0;
}

CodePudding user response:

 struct c_node * head=(struct c_node *) malloc (sizeof (struct c_node)); 
  • Related