Connecting Tech Pros Worldwide Forums | Help | Site Map

IO error reading variable in and printing it out.

Newbie
 
Join Date: May 2007
Posts: 1
#1: May 27 '07
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<math.h>
  3.  main()
  4. {
  5. double input,F,t;                                         
  6. scanf("%f\n",&input);
  7. printf("input= %f\n",input);
  8.  
in the output showing ,
satya@localhost programm]$ ./pow
13.0
input= 2.165711

Savage's Avatar
Expert
 
Join Date: Feb 2007
Posts: 1,737
#2: May 27 '07

re: IO error reading variable in and printing it out.


Quote:

Originally Posted by kollati

#include<stdio.h>
#include<math.h>
main()
{
double input,F,t;
scanf("%f\n",&input);
printf("input= %f\n",input);

in the output showing ,
satya@localhost programm]$ ./pow
13.0
input= 2.165711

Conversion string for double is %lf not %f.

Savage
kky2k's Avatar
Member
 
Join Date: May 2007
Location: bangalore
Posts: 34
#3: May 29 '07

re: IO error reading variable in and printing it out.


also remove \n from the scanf statment
sicarie's Avatar
Moderator
 
Join Date: Nov 2006
Location: USA
Posts: 3,929
#4: May 29 '07

re: IO error reading variable in and printing it out.


I have changed the title to better describe your issue - please let me or another moderator know if you think it should be something else.

Also, please read our Posting Guidelines which request you use code tags, create good thread titles, and actually ask a question in your posts. Thanks!
Reply