3 Replies - 328 Views - Last Post: 15 August 2011 - 07:41 AM Rate Topic: -----

#1 doug_byrne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 15-August 11

proper spacing between output, input all over the place i think...

Posted 15 August 2011 - 07:19 AM

Hey thanks for any help, what im trying and failing to do is produce the right amount of blank spaces in the output.
It should be as follows '--504-----302.56-----12.3'. I think im getting the input wrong...

#include "stdafx.h"

int
main(void)
{
	
	double a,
	       b,
	       c;
	
	/* input values for a, b, c  */

	printf("a value> \n");
	scanf("lf%", &a);

	printf("b value> \n");
	scanf("lf%", &B)/>;

	printf("c value> \n");
	scanf("lf%", &c);

        /*   output   */

	printf("\n %5f %11.2f %9.1f", &a, &b, &c);
	
	return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: proper spacing between output, input all over the place i think...

#2 jimblumberg  Icon User is online

  • member icon


Reputation: 3989
  • View blog
  • Posts: 12,309
  • Joined: 25-December 09

Re: proper spacing between output, input all over the place i think...

Posted 15 August 2011 - 07:32 AM

So what is the problem?

What does the actual output look like?

You are probably seeing the address of the variables instead of the actual values because of the ampersand in front of the variables in your printf. The printf function does not need the address of the variable ( &a ), it needs the contents of the variable ( a ).


Jim
Was This Post Helpful? 2
  • +
  • -

#3 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1624
  • View blog
  • Posts: 3,082
  • Joined: 30-May 10

Re: proper spacing between output, input all over the place i think...

Posted 15 August 2011 - 07:37 AM

> 14 scanf("lf%", &a);
Order of letters in a format conversion matters as well.
The % goes at the front.
Was This Post Helpful? 2
  • +
  • -

#4 doug_byrne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 15-August 11

Re: proper spacing between output, input all over the place i think...

Posted 15 August 2011 - 07:41 AM

Hey Jim,

Its not allowing me to input more than the first value and when i do input that first value its giving me numbers with huge amounts of characters, nothing like what i put in.

Thanks heaps for replying
Doug

Thanks Salem, thats what i was doing wrong haha, i doubt im ever going to pass this course...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1