【发布时间】:2021-07-24 13:44:31
【问题描述】:
我正在尝试获取四个变量名的输入。
我会在每个strtok_s 之后进行检查,看看我得到了什么,但第一个单词只在 4 个字符之后才算。
我的代码:
void zeros()
{
char buffer[81];
fgets(buffer, sizeof(buffer), stdin);
printf("%s\n", buffer);
char *command = strtok_s(buffer, " \t", &buffer);
printf_s("the command you selcted is %s\n", command);
char *Matname = strtok_s(NULL, " \t", &buffer);
printf_s("the name you selcted is %s\n", Matname);
char *row = strtok_s(NULL, " \t", &buffer);
printf_s("the rowsize you selcted is %s\n", row);
char *col = strtok_s(NULL, " \t", &buffer);
printf_s("the colsize you selcted is %s\n", col);
return 0;
}
【问题讨论】: