我想知道如何将文本保存在txt变量中?我想保持它单元我的功能将结束 - 我认为它被称为静态int
#include <stdio.h>
#include <stdlib.h>
int main()
{
char buf[1024];
char txt[100];
printf("Insert a text: ");
fgets(txt, 100, stdin);
snprintf(buf, sizeof(buf), "echo '%s'", txt);
system(buf);
}
谢谢, 马特
答案 0 :(得分:1)
您获得的错误与buf
的范围无关。
它引用system
函数,它只需要一个参数:
int system(const char *command)
希望我帮助过。