c++ problem with code

Hi,

I have a problem with my code. I'm trying to put the first name and name on the same line together. My getline doesn't seem to work. What am i missing?

Thanks

#include<iostream>
using namespace std;
#include<string>
#include<iomanip>

int main()

{
cout << endl;
cout <<setw(54)<<"Numero du cours: 420-P16-AS";
cout << endl;
cout <<setw(60)<<"Titre du cours : Programmation structuree";
cout << endl;
cout <<setw(54)<<"Professeur : Quang Hoang Cao";
cout << endl;
cout <<setw(51)<<"Session : Automne 2015";
cout << endl;cout << endl;
cout <<setw(54)<<"Sommaire des evaluations";
cout << endl;


int noEtudiant = 11111;
cout<<"\n\tEntrez le numero d etudiant: ";
cin>>noEtudiant;
cin.ignore();


string prenom = "";
cout<<"\n\tEntrez le prenom d etudiant: ";
cin>>prenom;


string nom = "";
cout<<"\n\tEntrez le nom d etudiant: ";
cin>>nom;


float noteProjet = 0.0f;
cout <<"\n\tEntrez la note du projet: ";
cin>>noteProjet;


float noteExamenIntra = 0.0f;
cout <<"\n\tEntrez la note de l examen intra: ";
cin>>noteExamenIntra;


float noteExamenFinal = 0.0f;
cout<<"\n\tEntrez la note de l examen final: ";
cin>>noteExamenFinal;

float resultat = 0.0f;
resultat=(noteProjet*0.3) + (noteExamenIntra*0.3) + (noteExamenFinal*0.4);

cout<<endl;
cout <<"No.Etudiant " <<"Nom Etudiant " << "Projet " <<"Examen Intra " <<"Examen Final "<<"Note finale"; cout<<endl;
cout <<"=========== " << "=========== " << "====== " <<"=========== " <<"============ " <<"==========" ; cout<<endl;
cout <<noEtudiant <<"\t\t" <<prenom <<nom <<"\t"<<noteProjet <<"\t"<<noteExamenIntra <<"\t\t"<<noteExamenFinal <<"\t\t" <<resultat; cout<<endl;




system ("pause");
return 0;

}
My getline doesn't seem to work. What am i missing?
A getline. There is no getline in your code.
I know, but my question is where should I put it in my code. and is there anything else to add?
my question is where should I put it in my code
Where do you need it? Why do you need getline?

Generally, you want to put getline after prompt to enter something which can contain spaces.

is there anything else to add?
Again, only you can know what your program needs.
Last edited on
My problem is when i enter the first name and after the last name, on my final result, i would like for them to be on the same line. Which is working but there are stick together. There is no space in between.
There is no space in between.
Output space after you output first name and before you output last name. If you want for something to be there, place it there.
Topic archived. No new replies allowed.