Question

This is a discussion on Question within the C++ Programming forums, part of the General Programming Boards category; Hi everyone. I am new to this board and new to programming as well. The scenario is that I am ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    9

    Question

    Hi everyone.
    I am new to this board and new to programming as well.

    The scenario is that
    I am having to read lines of text (unknown lines) from external file and I need to sort them in alphabetical order ( lines consist of last name, first name, and jobtitle) and write to a different external file.
    I am not allowed to use strings array but I am allowed to use
    strcpy, strlen, strcomp etc..

    I will read the first line as character array.
    store character array to other variable array(?)
    then I am lost. I think it's possible to use array of array?

    Any help is greatly appreciated.
    Thanks.

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Post the code that you have so far.

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    9
    #include <fstream.h>

    int main ()
    {
    ifstream in;
    ofstream out;
    char str[];
    char line[];


    // Open the files
    in.open ("cd.dat");
    out.open ("prog5.data");

    // Get data

    while (!in.eof())
    {
    char str [81];
    in.get (str, 80, '\n');
    in.get ();

    length = strlen (str);

    for (int i=0; i<length; i++)
    {
    strcpy (line[i], str[i]);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

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