I've made a very silly testing program, because for some reason
I can't conclude this most simple operation. Despite the value
I assign to t, it's always returning
s=-0.750000
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <stdio.h>
#include <stdlib.h>
int main () {
double t, s;
printf ("Enter a real number: \n");
scanf("%f", &t);
s=t-0.75;
printf ("s is %f \n", s);
system ("PAUSE");
return 0;
}
'cout' undeclared (first use this function)
'cin' undeclared (first use this function)
Now I'm using %lf and it's working. Thanks, JewelCpp. But I'm still having problems with characters, why does scanf work pretty well
with numbers, but not with characters? What can I possibily doing wrong?
With cout/cin you should #include <iostream> .
And, yes, you should really use cout/cin.
If you use C, use printf/scanf.
But you're using C++, use cout/cin.
Immediate benefit to using std::cin over scanf, you don't have specify what type of primitive you're handling. std::cin can even input std::string without specifying anything. Correct me if I'm wrong, but I don't believe std::string is even a primitive.