I have this function
void DadosDeCirculo(double *raio) {
printf("\nDigite o raio do circulo: ");
scanf("%f",&raio);
};
but the scanf is not working. I tried with *raio, raio, &(*raio) and *(&raio) but it keeps on value 0
pls help
o/
You might want to say which programming language it is. It looks exactly like c++ except you end the function definition with a }; ?
If you use c++, you should look into the iostream.h header, which gives you overloaded operators, that work like this:
cout << "This is a test output";
int number;
cin >> number;
That would output the message and then let the user enter a number.
sorry, I'm using C only
o/
The main problem is you are using a float format string to try and fill a double value (a double is a double precision float, a different type to float). What you want is:
void DadosDeCirculo(double *raio) {
printf("\nDigite o raio do circulo: ");
scanf("%lf",raio);
};
The "l" prefix on type like that means "long" so "li" means "long int", but paired with "f" it means a double.
Also note that I took the & off the raio in the scanf, this is because a pointer is passed in, and you want to fill the memory that the pointer points to, not the memory that the pointer is located at, that would be a big mistake.
thanks scotch
love you :**
o/