E
eliweiq001
#include <stdio.h>
#include <ctype.h>
int main(void)
{
int c;
scanf("%c", &c);
if ((!isdigit(c)) && (c != 'a'))
;
return 0;
}
I used ubuntu and gcc.
When this program is running in linux, it will case Segmentation fault
when reach the if sentence.
Also if I chang the && to || , it will effect the same thing.
If I chang "int c;" to "char c;", it won't cause that fault. ( I know
the regular way is to use char)
And it won't cause that fault if I chang " if ((!isdigit(c)) && (c !=
'a')) " to any sentence below:
"if ((c != 'a') && !isdigit(c));" or just "if (!isdigit(c));" or
just "if (c !='a');"
#include <ctype.h>
int main(void)
{
int c;
scanf("%c", &c);
if ((!isdigit(c)) && (c != 'a'))
;
return 0;
}
I used ubuntu and gcc.
When this program is running in linux, it will case Segmentation fault
when reach the if sentence.
Also if I chang the && to || , it will effect the same thing.
If I chang "int c;" to "char c;", it won't cause that fault. ( I know
the regular way is to use char)
And it won't cause that fault if I chang " if ((!isdigit(c)) && (c !=
'a')) " to any sentence below:
"if ((c != 'a') && !isdigit(c));" or just "if (!isdigit(c));" or
just "if (c !='a');"