C++ 错误:应为“;”,“,”或“=”标记之前的“')
fn print_列表中有一个错误,编译器显示以下错误C++ 错误:应为“;”,“,”或“=”标记之前的“'),c++,c,compilation,C++,C,Compilation,fn print_列表中有一个错误,编译器显示以下错误 error: expected ';', ',' or ')' before '=' token 请帮忙,因为我是新来的 我认为这不是语法错误,我无法按照我的预期识别代码中的问题,它应该正常工作。请告诉我函数print_列表中有什么问题,或者在调用同一函数时有什么问题 #include <stdio.h> #include <string.h> #include <stdlib.h> typedef
error: expected ';', ',' or ')' before '=' token
请帮忙,因为我是新来的
我认为这不是语法错误,我无法按照我的预期识别代码中的问题,它应该正常工作。请告诉我函数print_列表中有什么问题,或者在调用同一函数时有什么问题
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct node
{
int value;
struct node *next;
}mynode;
void add(mynode **, int);
void print_list(mynode *);
main()
{
mynode *head=NULL;
add(&head, 10);
add(&head, 100);
add(&head, 1000);
print_list(head);
}
void add(mynode **head_1, int value)
{
mynode *temp=NULL;
mynode ** head = head_1;
temp = malloc(sizeof(mynode));
temp->value = value;
temp->next = NULL;
if (*head == NULL)
{
*head = temp;
}
else
{
while(*head!=NULL)
{
*head = (*head)->next;
}
*head = temp;
}
return;
}
void print_list(mynode *head)
(
mynode *temp = head;
while(temp != NULL)
{
temp=temp->next;
printf("%d \t", temp->value);
}
)
使用{而不是
你用错大括号了
void print_list(mynode *head)
( //error should be {
mynode *temp = head;
while(temp != NULL)
{
temp=temp->next;
printf("%d \t", temp->value);
}
)//error should be }
在C块中,函数体必须使用{而不是,函数体以{开头
void print_list(mynode *head)
( //error should be {
mynode *temp = head;
while(temp != NULL)
{
temp=temp->next;
printf("%d \t", temp->value);
}
)//error should be }