Ok, this has been bothering me for about 30 minutes now. I cannot figure out why this code doesnt work. It compiles with no errors, but as soon as I enter the first number, it quits and gives me an error.
Code:
#include <stdio.h>
struct rect {
float length, width, height;
};
int main() {
struct rect box;
float volume=0;
printf("Please enter the length of the box: ");
scanf("%f", box.length);
printf("Please enter the width of the box: ");
scanf("%f", box.width);
printf("Please enter the height of the box: ");
scanf("%f", box.height);
volume = box.length * box.width * box.height;
printf("The volume of the box is: %f\n",volume);
if(box.length == box.width && box.width == box.height) {
printf("The box is a perfect cube\n");
}
else {
printf("The box is not a perfect cube\n");
}
return 0;
}