I define a variable as
float num1;

I try to use a scanf to read it
scanf("%f", num1);


I get some (what I think is a crazy response) statement expects a float, argument is a double

I am sure I must be doing something wrong because I also get this error
statement expects an int *, but argument is a int

I'm running Ubuntu Linux.
What am I doing wrong?
TYVM!!

Recommended Answers

All 2 Replies

scanf() expects the argument to be a pointer, and you passed just a float. Add the & to make num1 a pointer, like this: scanf("%f", &num1);

the operator & indicates the direction of the variable.
Ancient Dragon is right with the code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.