这是我的完整代码,每当我运行它时,它都会打印随机的负值,不确定是否出了问题。使用Ubuntu来运行和“ gcc -Wall -Wextra test.c”
#include <stdio.h>
int main () {
unsigned int x = 10;
unsigned int y = 16;
unsigned int p = x + y;
printf("%d\n", &p);
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试设置一个填充有'$'字符的10x10网格,然后进行打印。
char **plot;
plot = (char**)calloc(100, sizeof(char));
int i,j;
for (i=0; i< 10; i++) {
for(j=0; j<10; j++){
plot[i][j] = '$';
}
}
for (i=0; i<10; i++) {
for(j=0; j<10; j++) {
printf("%c", plot[i][j]);
}
}
free(plot);
Run Code Online (Sandbox Code Playgroud)
到目前为止,这是我的代码,当我运行此代码时,我遇到了分段错误。