How do I generate spaces into blank chars

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
 string my_string;
    cout << "This program allows you to store data in another location.";
 cout << "  ";
 cout << "Type all of what you want to save into the file";
 cout << "  ";
 system ("pause");
 ofstream myfile;
 myfile. open ("linkfile.txt");
 string x;
 cin >> x;
 myfile << x;
 myfile. close ();
return 0;
}
I need for my program to recognize spaces as blank chars so that you can input more then one word into the file. Help is greatly apreciated!
Last edited on
You could use std::getline(std::cin/*...*/) in order to read a whole line from the standard input.

Here's a bit of reading:
http://www.cplusplus.com/reference/string/getline/

Good luck!
-Albatross
You can use std::getline to read the whole line.
getline(cin, x);
Alright thanks for all of the help!
Topic archived. No new replies allowed.