I have to read a whole line from the console and store it into a std::string and a char array,
e.g.
"Hi this is balaji"
Now I have to read the above string and store it into string. I tried it using the getline() function.
I have to read a whole line from the console and store it into a std::string and a char array,
e.g.
"Hi this is balaji"
Now I have to read the above string and store it into string. I tried it using the getline() function.
 
    
     
    
    Try:
#include <string>
#include <iostream>
int main()
{
    std::string line;
    std::getline(std::cin, line);  // read a line from std::cin into line
    std::cout << "Your Line Was (" << line << ")\n";
    std::getline(std::cin, line);  // Waits for the user to hit enter before closing the program
}
 
    
    Maybe there's something wrong with how you use cin.getline()?
  cin.getline (name,256);
 
    
    Maybe
string a;
cin >> a;
cout << a << endl;
Or something like that?
