我似乎无法让我的 C 程序接受输入(直角棱柱计算器)

I can't seem to get my C program to take inputs (Rectangular Prism Calculator)

这是我第一次 post,所以我无法将 post 的代码直接输入文本框。

我遇到的问题是它自动生成数字而不是提示用户输入。我是 C 的新手,所以我不太明白我做错了什么。提前致谢。

#include <stdio.h>
#include <stdlib.h>



//function prototype
int getLength();
int getWidth();
int getHeight();

int vol (int, int, int);
int sA(int, int, int);
void disp(int, int);
int main()
{
    //declarations

    int a = 0;
    int b = 0;
    int c = 0;
    int volume = 0;
    int surfaceArea = 0;
    //input

    //calculation

    volume = vol(a, b, c);
    surfaceArea = sA(a, b, c);
    a = getLength;
    b = getWidth;
    c = getHeight;
    //output
    disp(vol,surfaceArea);
    return 0;
}//end main

//get length
int getLength()
{

    int length = 0;
    printf("enter length:  ");
    scanf("%d", &length);
    return length;
}


//get width
int getWidth()
{
    int width = 0;
    printf("enter width:  ");
    scanf("%d", &width);
    return width;
}

int getHeight()
{
    int height = 0;
    printf("enter height:  ");
    scanf("%d", &height);
    return height;
}
int vol(length, width, height)
{
    //return a * b * c
    int volume = 0;
    volume = (length * width * height);
    return volume;

}//end volume

int sA(length, height, width)
{
    //declare variables

    int wL1 = 0;
    int wL2 = 0;
    int wL3 = 0;
    int surfaceArea = 0;
    //breaking up into small portions
    wL1 = (width*length);
    wL2 = (height*length);
    wL3 = (height*width);
    surfaceArea = 2*(wL1+wL2+wL3);
    //return A=2(wl+hl+hw)
    return surfaceArea;

}//end surface area

void disp(volume,surfaceArea)
{
    //display results
    printf("The Volume of the Rectangular Prism is:   %d \n\n", volume );
    printf("The Surface Area of the Rectangular prism is:  %d", surfaceArea);
}

我想你想改变这个:

//Line 18
volume = vol(a, b, c);
surfaceArea = sA(a, b, c);
a = getLength;
b = getWidth;
c = getHeight;

//Line 33
disp(vol,surfaceArea);

//Line 64
int vol(length, width, height)

//Line 73
int sA(length, height, width)

//Line 91
void disp(volume, surfaceArea)

对此:

//Line 18
a = getLength();
           //^^Call the function and assign the value before you call functions with this variable
b = getWidth();
c = getHeight();
volume = vol(a, b, c);
surfaceArea = sA(a, b, c);

//Line 33
disp(volume, surfaceArea);
   //^^^^^^ vol doesn't exists i think you wanted to use volume

//Line 64
int vol(int length, int width, int height)
      //^^^ Declare the type of the variable, like in your prototype

//Line 73
int sA(int length, int height, int width)

//Line 91
void disp(int volume,int surfaceArea)
When calling a function, 
even a function with no parameters, 
the parens, after the function name are required.

also, using the following as an example, 
the code needs to check the returned value from calls to scanf() 
to assure the input/conversion operation was successful.

int getHeight()
{
    int height = 0;
    printf("enter height:  ");

    // note: leading space ' ' in format string
    //       to consume any left over white space, (like a newline)
    if( 1 != scanf(" %d", &height) )
    { // then scanf failed
        perror( "scanf for height failed" );
        exit( EXIT_FAILURE );
    }

    // implied else, scanf successful

    return height;
} // end function: getHeight