xcode - Pressing enter just makes another line in input in C -


I am trying to do that when I enter the input, it will go to the next part of the code:

  int first int second answer printf ("Enter first number \ n"); Scanf ("% d", and earlier); Printf ("Enter second number \ n"); Scanf ("% d", and second); First + second = answer printf ("% d", answer); Return 0  

This was just an example, but my code is:

  #include & lt; Stdio.h & gt; Int main () {int pennies; Full dollar; Printf ("How much money are in dollar dollars? \"); Scans ("% d", and dollars); Pennies = dollar * 100; Printf ("% d Pennies \ n", Panini); Return 0; }  

And when I run it on the terminal, it will ask "How much money are in dollar dollars?" Like it should be.

The problem is that when I type in 7, it will just leave a line and will run forever. Where am I trying to get it that when I enter, it is 7 * 100 times and the output is "700 Pennies" help please.

(Those who had seen this before, I had forgotten to remove very little ("% d% * c", dollar), and just scanf ("% d", dollar); And the solution does not work either)

I think that changing it:

< Pre> scans ("% d% * c", & amp; dollar);

From:

  scanf ("% d", and dollar);  

should resolve your problem because% * c leaves the character input, in this case perhaps your new line character


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -