.c文件编译(例程proc.c)
gcc proc.c -o proc
.cpp 文件编译(例程procpp.cpp)
g++ procpp.cpp -o procpp
-o 后为输出文件名
关于main函数参数
Example:
./QuoteClient 127.0.0.1
127.0.0.1即为argv
int main(int argc, char **argv)
{
printf("Connecting..\n");
if (argc != 2)
{
printf("Usage: ./%s ServerIPAddress\n", argv[0]);
exit(1);
}
printf("[Complete]Connect to Server %s\n",argv[0]);
//connected to server
...
}
网友评论