【发布时间】:2014-05-24 04:22:36
【问题描述】:
我正在尝试获取用户 argv 并在屏幕上打印结果。这是我的以下代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (int argc, char *argv[])
{
if (argc >= 1)
{
char *command = "gcc ";
strcat(command, argv[1]);
printf("%s", command);
return 0;
}
}
它可以编译,但每次我执行它时都会说“Windows 停止工作”。基本上,如果用户这样做:
myprogram.exe test
输出可能是
gcc test
我的错误在哪里?
【问题讨论】: