Thread: Help unsure

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    3

    Help unsure

    I need to know if I'm on the right track for this program problem
    Write a program that reads the attached text file. Each record in the file contains a name. You are to create an output file named names.csv. csv is the file extension for a comma delimited file. You are to create the csv file in such a way that the names in the input file wind up in columns rather than rows when you open the file in Excel. Let me know what I need to do to make this work or let me know if I'm on the right track.

    Thank you, Joel

    Jane
    Peter
    Joe
    Ann



    Source code

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


    int main ()

    {

    ifstream in_stream;
    ofstream out_stream;

    cout << "Edit files.\n";


    //open input file. If the file cannot be opened. Print fail statement and end.

    in_stream.open("namesin.txt");
    if(in_stream.fail())
    {

    cout <<"Input file opening failed.\n";

    exit(1);

    }


    // Open output file. If the file cannot be opened. Print fail statement and end.

    out_stream.open("names.csv");
    if(out_stream.fail())

    {

    cout <<"Output file opening failed.\n";

    exit(1);

    }

    char name[4];

    while(!in_stream.eof())
    {

    in_stream >> name;

    out_stream <<(name)<<"," <<endl;

    }

    in_stream.close();
    out_stream.close();

    cout << "End of files.\n";

    getchar();

    return 0;

    }

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    Don't double-post. If someone knows the answer to your question, they'll answer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to Forms/MFC. Unsure where to place the code.
    By Swerve in forum Windows Programming
    Replies: 1
    Last Post: 02-02-2009, 01:15 AM
  2. Unsure on how to approach this concurrency problem
    By osiris^ in forum C# Programming
    Replies: 3
    Last Post: 04-29-2008, 11:47 PM
  3. unsure about auto/smart pointers
    By l2u in forum C++ Programming
    Replies: 16
    Last Post: 07-13-2007, 12:55 PM
  4. Unsure of how to properly use extern "C"
    By INFERNO2K in forum C++ Programming
    Replies: 5
    Last Post: 11-11-2005, 11:54 AM
  5. unsure
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 08-13-2002, 09:37 AM