0
string line;
int input;

           stringstream linestream;
           cout << "\nEnter integer: ";
           getline(cin,line);                                                                       
           cout << "\nNumber is << line;

when i'm trying to print the String line: i'm getting the entered no plus some unknown numbers for eg. if i enter 951 the output would be 951 289792 some garbage and i don't want to use integer. And there is no cin>> statement b4 this code

WhozCraig
  • 65,258
  • 11
  • 75
  • 141
oomkiller
  • 169
  • 3
  • 11

1 Answers1

0

Works for me,

//stringstream linestream;
//extract to string
#include <iostream>
#include <string>

main ()
{
  std::string line;
  //int input;

  std::cout << "Enter integer: ";
  std::getline(std::cin,line);
  std::cout << "Number is " << line << std::endl;

  return 0;
}
ChuckCottrill
  • 4,360
  • 2
  • 24
  • 42