- 论坛徽章:
- 0
|
刚开始接触linux,编了一个非常简单的程序。
#include<iostream.h>
void main()
{
cout<<"hello,world!"<<enld;
}
命名为hello.cpp
编译:
gcc -o hello hello.cpp 然后就提醒:'main' must return 'int'
不应该啊。我把main 改成 int main ,
加入 return 2 还是编译不了。搞不懂啊,这是我在linux 下的第一个程序。
顺便问一下这个主函数带参数的程序:
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
if(argc!=2) {
printf("you forgot to type your name.\n");
exit(1);
}
printf("hello %s",argv[1]);
return 0;
}
我在VC下编译的时候要怎么样才能在运行的时候把参数写进去呢?
问题比较初级。
谢谢了。
[ 本帖最后由 modestyang 于 2006-9-13 17:31 编辑 ] |
|