Click here to Skip to main content
15,891,718 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#include <stdio.h>
#include <stdlib.h>
void pH(float *s);
void temp(float *s);
void co2(float *s);
int i=0;

struct Smart_Master
{
float pH, temp, co2;
};

int main()
{
    int c;
    printf("\aSMART MASTER GREENHOUSE\n");
    printf("\nlets get started!\n");
    system ("pause");
    system ("cls");
    printf(" \nWHAT DO YOU WANT TO KNOW?\n");
    printf("____________________________\n");
    printf("\n1.SOIL STATUS \n\n2.TEMPERATURE STATUS \n\n3.CONCENTRATION OF C02 \n\n");
    scanf("%d",&c);
    struct Smart_Master data[10]={};
    switch(c)
    {
    case 1:
        pH(data[i].pH);
        break;

    case 2:
        temp(data[i].temp);
        break;

    case 3:
        co2(data[i].co2);
        break;
    }


    return 0;
}
void pH(float *s)
{
  printf("hii\n");
}
void temp(float *s)
{

}
void co2(float *s)
{

}
error: incompatible type for argument 1 of 'pH'
(and will be the same for the 3 case)

What I have tried:

ive tried several time on declared other terms
Posted
Updated 2-Jul-20 7:43am
v2
Comments
ZurdoDev 2-Jul-20 12:51pm    
Sounds like the type of value your are trying to pass to pH function is not float.
jeron1 2-Jul-20 12:52pm    
Your functions are expecting a pointer to a float, you are passing by value (not a pointer to a float).

The parameter s is defined as pointer to float
void pH(float *s)
but you call pH in case 1 with a value parameter
pH(data[i].pH);

You have two options:
1.) Change the signature of the method pH to
void pH(float s)

2.) Change the part where you call the method pH to
pH(&(data[i].pH));


Personally I would choose option 1.

I hope it helps.
 
Share this answer
 
v2
Comments
CPallini 2-Jul-20 16:16pm    
5.
[no name] 3-Jul-20 1:41am    
Thank you
muhammad danial hakimi 3-Jul-20 11:14am    
thank you
[no name] 3-Jul-20 11:29am    
You are welcome. Thank you for accepting.
Beside all other issues is your
C++
struct Smart_Master data[10]={};
filled with zeros. So you wont see little. Initialize the members with some data to see it.

Tip: learn to use the debugger from some tutorial, because often in the bottom left is an area where you can watch the local data and expand it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900