小编Jam*_*ale的帖子

解析输入c时出错

您好我正在编写一个简单的c程序来测试解析c中的缓冲区但是当我运行该程序时,我得到以下错误:

./test.c: line 4: syntax error near unexpected token `('
./test.c: line 4: `int main()'
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么会发生这些错误?谢谢

#include <stdio.h>
#include <stdlib.h>

int main()
{

    char* command;

    char* buf = malloc(100 *sizeof(char));

    buf = "GET /index.html HTTP/1.1\n Host: www.gla.ac.uk\n";

    command  = strtok(buf, " ");
    printf("%s", command );

    free(buf);
}
Run Code Online (Sandbox Code Playgroud)

c parsing

-1
推荐指数
1
解决办法
55
查看次数

标签 统计

c ×1

parsing ×1