Thread: echo command

  1. #1

    Red face echo command


    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.

  2. #2
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Try this....

    #include <iostream>
    #include <fstream>

    using namespace std;

    ofstream output;

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

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

    //closes the output file 'file.txt'


    This should help (I hope)

    Last edited by face_master; 08-31-2001 at 07:33 PM.

  3. #3
    Join Date
    Aug 2001
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    echo Hello >> test.txt

    This works fine.
    I compile code with:
    Visual Studio.NET beta2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. problem with "touch" command in c program
    By Moony in forum C Programming
    Replies: 10
    Last Post: 08-01-2006, 09:56 AM
  3. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  4. A breakthrough
    By loopy in forum Linux Programming
    Replies: 4
    Last Post: 11-26-2003, 06:46 PM
  5. C-Shell Scripting.. Help!
    By denizengt in forum Tech Board
    Replies: 3
    Last Post: 10-29-2003, 01:37 PM