xcode练习c语言教材c primer plus 第六版6.7编程题时候。
我的代码如下,
#include
#include
int main(void)
{
printf("please enter a word:\n");
char word[40];
scanf("%s",word);
size_t j=strlen(word);
for(j-=1;j>=0;j--)
{
printf("%c",word[j]);
}
return 0;
}
请问strlen行用size_t声明为什么会发生错误?会出现\377等数字。
声明换成int后问题消失。运行正常。