我一直在努力弄清楚为什么它不会打印出测试消息并进入while
循环。有任何想法吗?
void getInput(char * string)
{
char * tempString;
int maxLength = 1026; // Accounts for NULL and \n.
tempString = malloc(maxLength * sizeof(char));
fgets(tempString, maxLength, stdin);
size_t len = strlen(tempString);
while ((int)len > maxLength)
{
printf("Test");
if (tempString[len-1] == '\n')
{
tempString[len-1] = '\0';
len = strlen(tempString);
} // if
} // while