简体   繁体   English

错误:在'='标记之前应为';',','或')'

[英]error: expected ';', ',' or ')' before '=' token

Here there is a error in the fn print_list() where the compiler is showing the following error 在fn print_list()中有一个错误,其中编译器显示以下错误

error: expected ';', ',' or ')' before '=' token

Please help since i am new in this. 请帮助,因为我是新来的。

i Think this is not the syntax error, i am not able to identify the problem in the code as per my expectation it should work correctly. 我认为这不是语法错误,按照我的预期,它无法在代码中识别出问题。 Please suggest me what is the problem in the function print_list or is there any problem in the call of the same function. 请建议我函数print_list中有什么问题,或者同一函数的调用中有什么问题。

#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);    
    }

    )

Use { instead of ( . 使用{代替(

void print_list(mynode *head)
{
    mynode *temp = head;
    while(temp != NULL)
    {
        temp=temp->next;
    printf("%d \t", temp->value);    
    }
}

You have used wrong braces 您使用了错误的牙套

 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 }

您必须使用{作为函数体,而不是'('

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM