所以我有这个scanf
scanf ("%30[^\n]%c", &i
我如何添加一个条件,如果用户输入超过 30 个字符,它会提示一条消息说有太多字符并让它们重新输入?
这是我的整个循环继续重新输入,直到输入正确但我没有设置正确的条件
int keeptrying = 1, rc;
char after, i;
do
{
rc = scanf ("%30[^\n]%c", &i, &after);
if (rc == 0)
{
printf (" **Invalid input try again: ");
clear();
}
else if (after != '\n')
{
printf (" **Trailing characters try again: ");
clear();
}
else if () // THIS IS WHERE I WOULD PUT THE CONDITION
{
printf (" **Title is longer than 30 characters: ");
}
else
{
keeptrying = 0;
}
} while (keeptrying == 1);
return i;