cout question...

This is a discussion on cout question... within the C++ Programming forums, part of the General Programming Boards category; Hey guys, you did such a wonderful job helping me last time, I figured I would bug you again I ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    6

    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;
    inFile.open("procedure.dat",ios::in);
    ofstream outFile;
    outFile.open("procedureout.dat",ios::out);
    while (!inFile.eof())
    {
    inFile.get(x);
    cout << x;
    outFile.put(y) << x;

    }


    inFile.close();
    outFile.close();

  2. #2
    Registered User ski6ski's Avatar
    Join Date
    Aug 2001
    Posts
    133
    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, 01:14 PM
  2. Default Arguments Question...
    By tinkerbell20 in forum C++ Programming
    Replies: 4
    Last Post: 07-07-2005, 06:27 PM
  3. Question about cout an stack object?
    By joenching in forum C++ Programming
    Replies: 8
    Last Post: 05-08-2005, 11:10 PM
  4. Question type program for beginners
    By Kirdra in forum C++ Programming
    Replies: 7
    Last Post: 09-15-2002, 06:10 AM
  5. cout question
    By The Gweech in forum C++ Programming
    Replies: 4
    Last Post: 07-09-2002, 05:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21