2 Replies - 225 Views - Last Post: 10 December 2012 - 03:56 PM Rate Topic: -----

#1 MrHatchi87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-October 12

help using getline compared to input

Posted 10 December 2012 - 03:44 PM

Hey there, my code is nearly perfect, but I need help with my input for a value. here's the snippet of my code:

cout << setw(15) << right <<"$" ;
			double Amount;
			input >> Amount;
			cout.setf(ios::showpoint);
			cout.setf(ios::fixed);
			cout.precision(2);
			cout.width(8);		
		input.ignore();
    	cout << Amount << endl;



i know that input puts a space after itself, and thats throwing off my output, how would i use getline instead of input?

** side note, im doing this on an online compiler, and its difficult to make changes (intellisense doesn't kick in)

Is This A Good Question/Topic? 0
  • +

Replies To: help using getline compared to input

#2 MrHatchi87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-October 12

Re: help using getline compared to input

Posted 10 December 2012 - 03:44 PM

Hey there, my code is nearly perfect, but I need help with my input for a value. here's the snippet of my code:

cout << setw(15) << right <<"$" ;
			double Amount;
			input >> Amount;
			cout.setf(ios::showpoint);
			cout.setf(ios::fixed);
			cout.precision(2);
			cout.width(8);		
		input.ignore();
    	cout << Amount << endl;



i know that input puts a space after itself, and thats throwing off my output, how would i use getline instead of input?

** side note, im doing this on an online compiler, and its difficult to make changes (intellisense doesn't kick in)
Was This Post Helpful? 0
  • +
  • -

#3 AKMafia001  Icon User is offline

  • </code.in.dream>

Reputation: 187
  • View blog
  • Posts: 625
  • Joined: 11-June 11

Re: help using getline compared to input

Posted 10 December 2012 - 03:56 PM

getline(input, Amount);    // Amount has to be string object


Read more about getline()...

Hope this Helps!

This post has been edited by AKMafia001: 10 December 2012 - 03:59 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1