www.digitalmars.com         C & C++   DMDScript  

c++.chat - I can't compile C programs w/input!

reply Pifs <Pifs_member pathlink.com> writes:
Sorry to bother you, but whenever i try to compile a program with
gets("%f", mph);      or printf("%f", &kmph);    in it, where im using gets()
for number inputand printf for number output, the compiler gives me the error:

1 actual arguments expected for printf, had 2

so, it seems to think that me setting the function up for printing numbers is
actually using 2 arguments, when it's not.  If you have advice on how i can fix
or prevent this from happening, please reply.

Pifs_of_blu
Jul 02 2004
parent "Nic Tiger" <tiger7 progtech.ru> writes:
Compiler may think of "printf" as taking 1 parameter only if you haven't
included stdio.h and compiler autoprototyped this functions from first call,
i.e:
    printf ( "..." );          // not knowing anything about printf,
compiler may think that it accepts only one param
    printf ( "%d", 2 );    // certainly compiler will give error here.

Make sure you #include <stdio.h> before you  use printf or scanf
Also, "gets" is not for formatted input, use scanf instead. But as for my
feeling, I don't like scanf and never had luck to make it work.
:-)

Nic Tiger.

"Pifs" <Pifs_member pathlink.com> wrote in message
news:cc51eq$19ic$1 digitaldaemon.com...
 Sorry to bother you, but whenever i try to compile a program with
 gets("%f", mph);      or printf("%f", &kmph);    in it, where im using

 for number inputand printf for number output, the compiler gives me the

 1 actual arguments expected for printf, had 2

 so, it seems to think that me setting the function up for printing numbers

 actually using 2 arguments, when it's not.  If you have advice on how i

 or prevent this from happening, please reply.

 Pifs_of_blu

Jul 04 2004