Thread: cout question...

  1. #1
    Registered User
    Join Date
    Dec 2001

    cout question...

    Hey guys, you did such a wonderful job helping me last time, I figured I would bug you again

    I am trying to pull information from one file to another file, and everytime I do that, it puts spaces between my characters, and doubles my last input so in essence file in is:

    I went to the store

    and the output to the other file is:

    I w e n t t o t h e s t o r ee

    The output on the screen is right except I get a double entry at the end as well. Any body got an idea? I am sure it has something to do with that crappy null character, but I still don't understand that fully. Any help would be appreciated. Here is my code:

    #include <stdio.h>
    #include <fstream.h>
    #include <iostream>

    char x;
    char y;

    void main()
    ifstream inFile;"procedure.dat",ios::in);
    ofstream outFile;"procedureout.dat",ios::out);
    while (!inFile.eof())
    cout << x;
    outFile.put(y) << x;



  2. #2
    Registered User ski6ski's Avatar
    Join Date
    Aug 2001
    Well the spaces are caused by the y variable. y is always empty therefore always a space. Take out the y and the spaces should be gone.

    As for the double e, I think it has to do with this:
    cout << x;
    outFile.put(y) << x;
    C++ Is Powerful
    I use C++
    There fore I am Powerful

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. Default Arguments Question...
    By tinkerbell20 in forum C++ Programming
    Replies: 4
    Last Post: 07-07-2005, 05:27 PM
  3. Question about cout an stack object?
    By joenching in forum C++ Programming
    Replies: 8
    Last Post: 05-08-2005, 10:10 PM
  4. Question type program for beginners
    By Kirdra in forum C++ Programming
    Replies: 7
    Last Post: 09-15-2002, 05:10 AM
  5. cout question
    By The Gweech in forum C++ Programming
    Replies: 4
    Last Post: 07-09-2002, 04:11 PM