Note that there are some explanatory texts on larger screens.

plurals
  1. POerrors and warning message when using pointer
    primarykey
    data
    text
    <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;math.h&gt; #define CONST 267 void getInput(int *length, int *width, int *height); void calcoutput(int length, int width, int height, int *squareFootage,int *paintNeeded); int getSquareFootage(int length,int width, int height); double getPaintNeeded(int squareFootage); int main(void) { int length; int width; int height; int squareFootage; double paintNeeded; getInput(&amp;length, &amp;width, &amp;height); calcoutput(length, width, height,&amp;squareFootage,&amp;paintNeeded); return 0; } //end main void getInput(int *plength, int *pwidth, int *pheight) { printf("Enter the length of the room (whole number only): "); scanf("%d", plength); printf("Enter the width of the room (whole number only): "); scanf("%d", pwidth); printf("Enter the height of the room (whole number only): "); scanf("%d", pheight); } //end getInput void calcoutput(int length, int width, int height, int *squareFootage,int *paintNeeded){ *squareFootage = getSquareFootage(length,width, height); *paintNeeded = getPaintNeeded(squareFootage); } int getSquareFootage(int length,int width, int height){ int i; i = 2*(length* height) + 2*(width*height) + (length* width); return i; } double getPaintNeeded(int squareFootage) { double i = double (squareFootage / CONST); return i; } </code></pre> <p>i'm writing this code to calculate the area of the room and number of gallons of paint needed to paint the room, however, I'm not very familiar with pointers in C, there seems to be some errors and warning like this </p> <pre><code>C:\Users\khoavo\Desktop\hw2b.c||In function 'main':| C:\Users\khoavo\Desktop\hw2b.c|23|warning: passing argument 5 of 'calcoutput' from incompatible pointer type| C:\Users\khoavo\Desktop\hw2b.c|8|note: expected 'int *' but argument is of type 'double *'| C:\Users\khoavo\Desktop\hw2b.c||In function 'calcoutput':| C:\Users\khoavo\Desktop\hw2b.c|41|warning: passing argument 1 of 'getPaintNeeded' makes integer from pointer without a cast| C:\Users\khoavo\Desktop\hw2b.c|10|note: expected 'int' but argument is of type 'int *'| C:\Users\khoavo\Desktop\hw2b.c||In function 'getPaintNeeded':| C:\Users\khoavo\Desktop\hw2b.c|52|error: expected expression before 'double'| ||=== Build finished: 1 errors, 2 warnings ===| </code></pre> <p>how will I be able to fix these errors and warning ? thank you in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload