Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 错误:应为“;”,“,”或“=”标记之前的“')_C++_C_Compilation - Fatal编程技术网

C++ 错误:应为“;”,“,”或“=”标记之前的“')

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

fn print_列表中有一个错误,编译器显示以下错误

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 }