Hello,
I'm beginner, just trying to write words and phrases into text document, on each cycle one line under another like this.
1 2 3 4
|
word1
word2
word3
etc.
|
it is works with numbers but if I'm use char I got separated characters like this:
Can you show me some example to figure out with this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
using namespace std;
std::ofstream outfile("doc.txt");
int main()
{
std::string a;
for (int i = 0; i < 10; i++)
{
cout << "Write word: " << endl;
cin >> a;
cout << "ID: " << i << a << endl;
outfile << a << std::endl;
}
_getch();
return 0;
}
|
Last edited on
Why do you use srand(time(NULL));
? This line is redundant.
Hello, thank you, I've edited above with your help, now works. what about time, I'm just wondering how to make time interval for each cycle
Last edited on
http://www.cplusplus.com/reference/ctime/clock/