#include <stdio.h>
#include <ctype.h>
#define int long
int main ()
{
char c;
int i=0;
char str[]="Example sentence to test isspace\n";
while (str[i])
{
c=str[i];
if (isspace(c)) c='\n';
putchar (c);
i++;
}
return 0;
}
它在linux环境下出错,因为:
isspace
将扩展为
if (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISspace)) c='\n';
当我通过宏将 int 更改为 long 时,它将变为
if (((*__ctype_b_loc ())[(long) ((c))] & (unsigned short long) _ISspace)) c='\n';
因此它会引发错误,请提供答案。