Thread: Input problem

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    2

    Input problem

    Hi guys~

    I require an input that will accept a measurement in feet and pounds, i.e. 5'6

    So I have this so far:

    Code:
        cout << "Enter your height: " ;
        float x, y ;
        cin >> x >> y;
    However, my programme is unable to read the apostrophe.
    Any hints?

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Quote Originally Posted by blimsiang View Post
    Hi guys~

    I require an input that will accept a measurement in feet and pounds, i.e. 5'6

    So I have this so far:

    Code:
        cout << "Enter your height: " ;
        float x, y ;
        cin >> x >> y;
    However, my programme is unable to read the apostrophe.
    Any hints?
    You read two float numbers. You should read a float, a character (the apostrophe) and a float number. Try that. I guess it reads only the 5 eh?

    EDIT: Some code:
    Code:
    #include <iostream>
    using namespace std;
    
    int main(void)
    {
    	float x, y;
    	char c;
    	cin >> x >> c >> y;
    	cout << x << " " << y;
    }
    Last edited by C_ntua; 09-11-2008 at 03:59 AM.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    2
    SWEET.
    Thanks mate~

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. geting input in C, problem in getting input
    By BujarM in forum C Programming
    Replies: 3
    Last Post: 04-17-2009, 09:38 PM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. Input statement problem
    By une in forum C Programming
    Replies: 3
    Last Post: 05-29-2007, 11:16 PM
  4. Problem with File Input & Pointers
    By jenna in forum C++ Programming
    Replies: 9
    Last Post: 12-04-2004, 11:34 PM
  5. Problem with text input
    By newbie in forum C++ Programming
    Replies: 2
    Last Post: 03-10-2002, 04:44 PM