Results 1 to 23 of 23

Thread: cin.getline() Not Working?

Threaded View

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    cin.getline() Not Working?

    It's been awhile since I've used C++. Why doesn't this work?

    Code:
    #include <iostream>
    using namespace std;
    
    int main() {
    
    	//input variables:	
    	char destination[20], datedepart[8], datereturn[8];
    	double ticketprice;
    	int ticketcount;
    
    	cout << "Destination: ";
    	cin.getline(destination, 20);
    
    	cout << "Departure Date: ";
    	cin >> datedepart;
    	
    	cout << "Return Date: ";
    	cin >> datereturn;
    	cout << "Number of Tickets: ";
    	cin >> ticketcount;
    	cout << "Price per Ticket: ";
    	cin >> ticketprice; 
    
    	cout << endl << destination << endl << endl;
    
    	return 0;
    
    }
    For destination it outputs nothing?

    Example Input would be:

    Destination: Florida
    Depart Date: 12/01/02
    Return Date: 12/11/02
    Number of Tickets: 2
    Price per Ticket: 345.00
    Last edited by The Hobo; Sep 13th, 2002 at 03:06 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width