#define HISTORY_SIZE 50
#define INPUT_SIZE 512 /*Max input size*/
char input[INPUT_SIZE]; /*Holding user input globaly*/
char* input_history[HISTORY_SIZE];
这是IM存储在输入我的输入,并想保存它的一个副本如何以input_historyC:获取用户输入,存储,延续着则显示过去50个输入
void addToHistory()
{
/*input_history[currentHistorySize++] = strtok(input,"\n");*/
input_history[currentHistorySize++] = input;
printf("ADDEDTOHISTORY: %s \t\t %d \n", input_history[(currentHistorySize- 1)],currentHistorySize);
}
但当我去把它打印出来,它不工作....
/*strcpy(input,input_history[currentHistorySize-2]);
printf("LAST INPUT, %s \n %s \n \n", input,input_history[currentHistorySize-2]);*/
printf("0: %s \n ", input_history[0]);
printf("1: %s \n ", input_history[1]);
printf("2: %s \n ", input_history[2]);
我一直坐在努力工作,这一点对于年龄和不能似乎看到我去错了,也许是一双新的眼睛会注意到一些愚蠢的错误?
Basicly我想用
fgets(input,INPUT_SIZE,stdin)
然后它的副本存储成char * input_history ,然后可以将其打印出来以后拿用户输入。
很简单。
定义“不起作用”。 – cnicutar 2012-03-21 11:38:28