Segmentation fault when casting int to char in C
问题 I have a very simple C program. In main, I have this operation: int main(){ int theNumber = 9009; printf("%s", (char *)theNumber); } And when I run it, it gives me a seg fault. Any idea why? Am I doing this wrong? Expected Output This code should convert theNumber to a string and then print it. So the output would be: 9009 Actual Output A segmentation fault. 回答1: This is trying to print whatever is found at the address 9009 . Seeing as the operating system is not giving your program access to