我的c程序怎么老是弄不出来阿
-
- 帖子: 36
- 注册时间: 2007-05-11 19:48
- 来自: 湖北襄樊
我的c程序怎么老是弄不出来阿
我一直都不能完成最基本的C程序!
我想输入一个简单的C程序HELLO WORLD
是这样编译的:
#include <stdio.h>
int main()
{
printf("Hello, world!\n");
return 0;
}
存为并退出:hello.c
在终端输入:gcc -o hello.c vi.c回车
出现:
wangxuyuan@wangxuyuan-laptop:~$ gcc -o hello.c vi.c
gcc: vi.c:No such file or directory
gcc: 没有输入文件
wangxuyuan@wangxuyuan-laptop:~$
这是怎么回事阿,大家能看看我是那里出错了?
C程序我在很多地方找到的都不一样!这是怎么回事?
如:我在书上看到的:
#include<iostream>
int main()
{
std::cout<<"hello world!\n;
return 0;
}
我想输入一个简单的C程序HELLO WORLD
是这样编译的:
#include <stdio.h>
int main()
{
printf("Hello, world!\n");
return 0;
}
存为并退出:hello.c
在终端输入:gcc -o hello.c vi.c回车
出现:
wangxuyuan@wangxuyuan-laptop:~$ gcc -o hello.c vi.c
gcc: vi.c:No such file or directory
gcc: 没有输入文件
wangxuyuan@wangxuyuan-laptop:~$
这是怎么回事阿,大家能看看我是那里出错了?
C程序我在很多地方找到的都不一样!这是怎么回事?
如:我在书上看到的:
#include<iostream>
int main()
{
std::cout<<"hello world!\n;
return 0;
}
-
- 帖子: 99
- 注册时间: 2006-06-09 9:37
-
- 帖子: 36
- 注册时间: 2007-05-11 19:48
- 来自: 湖北襄樊
-
- 帖子: 99
- 注册时间: 2006-06-09 9:37
-
- 帖子: 3182
- 注册时间: 2006-03-10 15:10
- 来自: xi'an China
- 联系:
w3484732 写了:wangxuyuan@wangxuyuan-laptop:~$ gcc -o aaa hello.c
hello.c:1:19: 错误: stdio.h:No such file or directory
hello.c: 在函数 ‘main’ 中:
hello.c:5: 警告: 隐式声明与内建函数 ‘printf’ 不兼容
wangxuyuan@wangxuyuan-laptop:~$
不行!是不是我写的程序有问题?
代码: 全选
sudo apt-get install build-essential
-
- 帖子: 36
- 注册时间: 2007-05-11 19:48
- 来自: 湖北襄樊
哦!那我先去装!
现在出现了个问题!
我退出VIM后再使用:vim hello.c打开我编译的文件时出现:
E325: ATTENTION
Found a swap file by the name ".hello.c.swp"
owned by: wangxuyuan dated: Mon Mar 10 20:54:54 2008
file name: ~wangxuyuan/hello.c
modified: YES
user name: wangxuyuan host name: wangxuyuan-laptop
process ID: 10175
While opening file "hello.c"
dated: Mon Mar 10 20:12:36 2008
(1) Another program may be editing the same file.
If this is the case, be careful not to end up with two
different instances of the same file when making changes.
Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r hello.c"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".hello.c.swp"
to avoid this message.
"hello.c" 7L, 74C
Press ENTER or type command to continue
完后点个回车就好了,这是怎么回事?
现在出现了个问题!
我退出VIM后再使用:vim hello.c打开我编译的文件时出现:
E325: ATTENTION
Found a swap file by the name ".hello.c.swp"
owned by: wangxuyuan dated: Mon Mar 10 20:54:54 2008
file name: ~wangxuyuan/hello.c
modified: YES
user name: wangxuyuan host name: wangxuyuan-laptop
process ID: 10175
While opening file "hello.c"
dated: Mon Mar 10 20:12:36 2008
(1) Another program may be editing the same file.
If this is the case, be careful not to end up with two
different instances of the same file when making changes.
Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r hello.c"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".hello.c.swp"
to avoid this message.
"hello.c" 7L, 74C
Press ENTER or type command to continue
完后点个回车就好了,这是怎么回事?
-
- 帖子: 3182
- 注册时间: 2006-03-10 15:10
- 来自: xi'an China
- 联系:
-
- 帖子: 36
- 注册时间: 2007-05-11 19:48
- 来自: 湖北襄樊
- Yizer
- 帖子: 297
- 注册时间: 2007-11-07 14:41
- 来自: 佳木斯
- 联系:
- zhihuasz
- 帖子: 665
- 注册时间: 2008-01-01 17:25
- 来自: 深圳
- 联系:
-
- 帖子: 36
- 注册时间: 2007-05-11 19:48
- 来自: 湖北襄樊
现在又来了个问题:
我把编译好的程序做了改动,用GCC就编译不了了,怎么回事阿?
实际情况:
编译后能运行的:
#include <stdio.h>
int main()
{
printf("Hello, wo1111111111111111111111rld!\n");
return 0;
}
再改动后的:
#include <stdio.h>
int main()
{
printf("Hello, w1orld!\n");
return 0;
}
使用GCC命令:
第一个:
wangxuyuan@wangxuyuan-laptop:~$ gcc -o wang hello.c
wangxuyuan@wangxuyuan-laptop:~$
第二个:
123: file not recognized: File format not recognized
collect2: ld 返回 1
wangxuyuan@wangxuyuan-laptop:~$
第二个告诉我说: 文件形式不承认。这是怎么回事阿?
我把编译好的程序做了改动,用GCC就编译不了了,怎么回事阿?
实际情况:
编译后能运行的:
#include <stdio.h>
int main()
{
printf("Hello, wo1111111111111111111111rld!\n");
return 0;
}
再改动后的:
#include <stdio.h>
int main()
{
printf("Hello, w1orld!\n");
return 0;
}
使用GCC命令:
第一个:
wangxuyuan@wangxuyuan-laptop:~$ gcc -o wang hello.c
wangxuyuan@wangxuyuan-laptop:~$
第二个:
123: file not recognized: File format not recognized
collect2: ld 返回 1
wangxuyuan@wangxuyuan-laptop:~$
第二个告诉我说: 文件形式不承认。这是怎么回事阿?
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系: