我是全新的编程..我只是想让我自己的程序找到球体和圆柱体的体积和表面积。我无法弄清楚为什么这个程序在它到达代码的其余部分之前会一直崩溃。我猜char*
可能是错的,但我不明白为什么会这样。它正在编译但每次崩溃
int main()
{
char* solid;
char* unit;
printf("Welcome to the Center of Spheres and Cylinders!\n");
printf("Would you like to look at a Sphere or a Cylinder?: ");
scanf("%s", solid);
if(solid == "Cylinder" || solid == "cylinder")
{
printf("You chose to look at a Cylinder.\n");
else if(solid == "Sphere" || solid == "sphere")
{
printf("You chose to look at a Sphere.\n");
崩溃刚过我输入scanf.
..when我任一气缸中键入或球体崩溃。感谢您的帮助
所以我决定宣布它作为一个数组,并停止崩溃!但现在只是没有执行任何其他代码...它将采取从 scanf(“%s”,固体)的输入; 但程序结束.. 再次感谢您的帮助 – Karssassin