FA-Step One

This is a discussion on FA-Step One within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream.h> #include <fstream.h> #include <string.h> struct qtype { char board [80]; char title [80]; char body [80]; }; ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    10

    FA-Step One

    Code:
    #include <iostream.h> 
    #include <fstream.h> 
    #include <string.h> 
    
    struct qtype { 
    char board [80]; 
    char title [80]; 
    char body [80]; 
    }; 
    
    void getboard {(qtype item); 
    ifstream sourcefile ("board.txt"); 
    
    if (sourcefile.fail()) 
    cerr << "Error opening board.txt..."; 
    else 
    (while ! sourcefile.eof()); 
    strcpy (item.board); 
    
    
    sourcefile.close(); 
    return; 
    }; 
    
    void gettitle {(qtype item); 
    ifstream sourcefile ("title.txt"); 
    
    if (sourcefile.fail()) 
    cerr << "Error opening title.txt..."; 
    else 
    (while ! sourcefile.eof()); 
    strcpy (item.title); 
    
    
    sourcefile.close(); 
    return; 
    }; 
    
    void getbody {(qtype item); 
    ifstream sourcefile ("body.txt"); 
    
    if (sourcefile.fail()) 
    cerr << "Error opening body.txt..."; 
    else 
    (while ! sourcefile.eof()); 
    strcpy (item.body); 
    
    
    sourcefile.close(); 
    return; 
    }; 
    
    void output { 
    cout << board << endl; 
    cout << title << endl; 
    cout << body << endl; 
    
    };
    Ok, this is my second try at C++. My first was a test, submitted by one of your board members, that produced the desired results "hello world!", it worked, I had fun, now I want to move on to step one.

    If you would like to reveiw my goal with this program, how it applies to forums such as this one and FAQ's, see my "Forums Autoresponder" post.

    The goal with this first step is to load 3 strings, an address, a title, and a body, and then output them to the screen. This is simple enough. Output should look like this

    board
    title
    post

    if "board.txt" contained "board"
    etc....
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    I get an error at line 11, and do not know if that is

    void getboard {(qtype item);

    or

    if (sourcefile.fail())

    to rephrase that question, does the line number include empty lines?

    Will this program work for the above goals, and how do I fix it to do so? I think removing the extra { will work

    The next step would be to add the variables for multiple results.

    board
    title
    post

    board2
    title2
    post2

    board3
    title3
    post3

    if "board.txt" contained "board,board2,board3"
    etc...

    And lastly, Im using a java compiler to test my program out because I do not know how to compile it with the digatilmars C++ compiler I have. Seems kinda stupid, I know, but how do I compile this on my computer, instead of online?
    Last edited by rev_happy; 03-26-2002 at 01:53 AM.

  2. #2
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    C'mon, can't you just stop this?

    If there actually are people here that are willing to answer all the questions then why do we need a program to do it?

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    10

    Why have a FAQ at all, then?

    We have people here to answer the hard questions. The one above can not be answered by a FAQ or autoresponder.

    What if I asked "how do I create a browser?"

    This question only need be answered once, with a response fulla links.

    The autoresponder would automatically answer, and thus filter out the easy questions, leaving the hard ones for the experts.

    I apologize for this string. It is a repost of the same question, as an attempt to "break it down" and solve part of the problem.

    After I posted it, I found out it may be bad etiquette.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. recursion
    By paulmedic555 in forum C Programming
    Replies: 26
    Last Post: 01-27-2005, 11:43 PM
  2. robot step sizes
    By n00by in forum C Programming
    Replies: 2
    Last Post: 04-29-2004, 03:29 PM
  3. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 06:18 AM
  4. step by step debug != run debug
    By bonkey in forum Windows Programming
    Replies: 8
    Last Post: 09-09-2002, 12:55 PM
  5. this sites Compiler Resources Specs.
    By Powerfull Army in forum C++ Programming
    Replies: 9
    Last Post: 07-08-2002, 06:12 PM

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