意外令牌'('附近的语法错误 [英] Syntax error near unexpected token '('
问题描述
作为一个初学者,我正在尝试编写一个简单的c程序来学习和执行写"功能.
As a beginner, I am trying to write a simple c program to learn and execute the "write" function.
我正在尝试执行一个简单的C程序simple_write.c
I am trying to execute a simple c program simple_write.c
#include <unistd.h>
#include <stdlib.h>
int main()
{
if ((write(1, "Here is some data\n", 18)) != 18)
write(2, "A write error has occurred on file descriptor 1\n",46);
exit(0);
}
我还执行chmod + x simple_write.c
I also execute chmod +x simple_write.c
但是当我执行./simple_write.c时,它在意外令牌'('
But when i execute ./simple_write.c, it gives me syntax error near unexpected token '('
无法弄清楚为什么会发生这种情况??
Couldn't figure out why this happens ??
P.S:预期输出为:-
P.S: The expected output is:-
$ ./simple_write
Here is some data
$
推荐答案
好,
我做错了.
这些是我纠正问题所采取的步骤:-
These are the steps that I took to get my problem corrected:-
-
$ gedit simple_write.c
将代码写入该文件并保存(扩展名为.c).
Write the code into this file and save it (with .c extension).
$ make simple_write
$ ./simple_write
我得到了想要的输出.
谢谢!
这篇关于意外令牌'('附近的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!