I need help with this problem

This is a discussion on I need help with this problem within the C++ Programming forums, part of the General Programming Boards category; Greetings, I have this program that runs w/o any errors but I am curious why its output looks like this. ...

  1. #1
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Exclamation I need help with this problem

    Greetings,
    I have this program that runs w/o any errors but I am curious why its output looks like this. My input is 1 2.2 3 4.4 5 6.6 w/o any characters. I would think it woould print 1 (space, since there is no char) then 2,2 etc... I am curious if anyone can explain to me why it does this.

    Code:
    #include <iostream>	// cin, cout, >>, <<
    #include <string>	// used for char
    using namespace std;
    
    int main()
    {
    	int i1, i2, i3;
    	char c1, c2, c3;
    	double r1, r2, r3;
    
    	cin >> noskipws 
    		>> i1 >> c1 >> r1
    		>> i2 >> c2 >> r2
    		>> i3 >> c3 >> r3;
    
    	cout << i1 << c1 << r1
    		 << i2 << c2 << r2
    		 << i3 << c3 << r3;
    		return 0;
    }

  2. #2
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    Perhaps you forgot there's another space between 2.2 and 3.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 05:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21