PDA

View Full Version : echo command



Billing
08-29-2001, 09:49 AM
Hello

How can I create a text file by using dos commands?

I am trying to use echo command such as
echo Hello > test.txt
echo Hi, how are you? >> test.txt

But, the echo doesn't put any null terminator at the end of string.
When I check the string length of each, it should be 5 for Hello.
It is not, it become the length of buffer that read the line.

Anyone, please give me a suggestion.

Thank you.
Pong

face_master
08-31-2001, 07:31 PM
Try this....



#include <iostream>
#include <fstream>

using namespace std;

main()
{
ofstream output;

//opens file 'file.txt' for writing to.
output.open("file.txt");

//writes information to the file 'file.txt'
output << "Hello";

//closes the output file 'file.txt'
output.close();


}

This should help (I hope)

-Chris

Witch_King
08-31-2001, 08:38 PM
echo Hello >> test.txt

This works fine.