Showing posts with label Getline. Show all posts
Showing posts with label Getline. Show all posts

Tuesday, 13 March 2012

Problem Getline is solved

Getline function sometimes runs badly i mean it's work useless for us so i can help you about getline's useless

/***************************************************************************** 

   using getline function/getline fonksiyonun istenildiği gibi kullanılması

******************************************************************************/
#include<string>
#include<iostream>

using namespace std;

void main(){
string film_name,country;
bool oscar;
int duration,number_of_actors;
double imdb_rating;
string getliner;

cout << "Please enter film's name : " << "\n";
cin.ignore(0,'\n'); //not read space and nextline character
getline(cin,film_name);

cout  << "Please enter film's year : "<< endl;
cin >> year;

cout  << "Please enter film's duration : "<< endl;
cin >> duration;

cout  << "Please enter number of actors : "<< endl;
cin >> number_of_actors;
getline(cin,getliner);

cout  << "Please enter film's country : "<< "\n";
cin.ignore(0,'\n');  //not read space and nextline character
getline(cin,country);

cout  << "Does the film have Oscar 0 or 1 : "<< endl;
cin >> oscar;

cout  << "Please enter imdb rating of the film : "<< endl;
cin >> imdb_rating;
getline(cin,getliner);

cout << "Film added" << endl;

cin.clear();
}