-2
我想知道我怎麼能保持在TXT變量的文本?我想保持它unitl我的功能將結束 - 我想,這就是所謂的靜態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);
}
謝謝, 馬特
'txt'將被保留,直到其範圍結束。你能澄清你的問題嗎?上述代碼的問題究竟是什麼? – Mureinik
「*我想保持它unitl我的功能將結束*」它已經這樣做 –
如果選中它是靜態的,它會被保留,直到你的* *程序結束。這是你問的嗎? –