Help me with my c++ homework please

This is a discussion on Help me with my c++ homework please within the C++ Programming forums, part of the General Programming Boards category; This is the input file I must use names.txt- Franklin Delano Roosevelt Abraham Lincoln William Henry Harrison John Fitzgerald Kennedy ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Location
    Cincinnati, Oh
    Posts
    25

    Help me with my c++ homework please

    This is the input file I must use names.txt-

    Franklin Delano Roosevelt
    Abraham Lincoln
    William Henry Harrison
    John Fitzgerald Kennedy
    Rutherford Birchard Hayes
    Thomas Jefferson
    James Monroe
    Thomas Woodrow Wilson
    Warren Gamaliel Harding
    John Quincy Adams
    Franklin Pierce
    Dwight David Eisenhower
    Stephen Grover Cleveland
    James Knox Polk

    I must call the file in my main program and using c strings I have to organize them in a last name first format. For example for the first one I must put the name in the output file as Roosevelt, Franklin D. I must do it in this format for all of the names. This is what i have so far and I am stuck. I am having trouble in my function.

    Code:
    //-------------------------------------------------------------------------
    // File----------- Names 
    // Programmer---
    // Course--------- CSC115
    // Project-------- Program #9
    // Due------------ December 8, 2010
    //
    // This program takes the names of individuals kept in a seperate input file and 
    // puts them in the last name first format and puts them back in an output file. 
    //--------------------------------------------------------------------------
    
    
    #include <iostream>
    #include <fstream>
    #include <cstring>
    
    void reverseName(char inName[], char outName[]);
    using namespace std;
    int main ()
    {
    	inputfile = names.txt
    	outputfile = newnames.txt
    	char inName;
    	char outName;
    
    
    	cout<< "Select Input File:"; 
    	cin>> inputfile; 
    	cout<< endl;
    
    	cout<< "Select Output File:";
    	cin>> outputfile;
    	cout<< endl;
    
    //-----------------------------
    //Name Function
    //-----------------------------
    #include <iostream>
    #include <fstream>
    #include <cstring>
    
    using namespace std;
    	
    	void reverseName(char inName[], char outName[]){
    		
    		ifstreaminputfile;
    		char inName[100];
    		char reverseName;
    		char originalName;
    		n= pieceCount(name);
    
    		inputfile.open(names.txt);
    			inputfile.fail
    			inputfile.getline(line,0);
    			while(!inputfile.eof()){
    				
    
    return 0;
    			}

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    2,560
    So you are having problems in your function.

    May I ask what kind of problems?

    Perhaps you have some error/warning messages you would like to share.

    Maybe you could describe the problem just a little bit for us.


    Jim

  3. #3
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,641
    I'm guessing the problem is the assignment is pretty much a bunch of pseudocode he threw down in the editor and he's waiting for one of us to make it work. Just a hunch. It's certainly nowhere near compilable.

  4. #4
    Registered User
    Join Date
    Oct 2010
    Location
    Cincinnati, Oh
    Posts
    25
    No it does not compile, but everyone on this forum is so quick to jump to the conclusion that everyone wants them to do their homework for them. I don't want that I would prefer to know how to do it. I was hoping for some suggestions to what i should do or do next or change. Thanks.

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    2,560
    I was hoping for some suggestions to what i should do or do next or change.
    Since you have decided not to share your error messages or problem description if I were you, I would probably start by reading my error messages and fixing them.

    Jim

  6. #6
    Registered User
    Join Date
    Dec 2010
    Posts
    25
    You didn't include the libraries correctly because you just copied and pasted the function from some file without knowing what you were doing. You can't include files like that.

    You messed up your main loop because you pasted a function right in the middle of it.

    Not to mention you have some bracket problems because you copied and pasted without paying attention to the while loop and function brackets or main brackets.

    Programs are designed like this generally:

    // Include statements
    // #defines and macros
    // Structures or Unions
    // Function Declarations

    // Int main() loop

    // Function Definitions

    What you have done was paste a function definition in the middle of the main loop instead of under it. Not to mention C++ requires function definitions as well as declarations, so you are missing a declaration above main.

    The newbieness of these mistakes has led people to believe you are copying and pasting a handout instead of actually trying to do your homework.

    Furthermore, since you are using files (or trying to...) in this assignment I assume this is NOT your first programming assignment with C++. No class would begin with files. Therefore it leads me to think you haven't kept up with your studies.

    Fess up your crimes, tell us what's the matter and we will give you some real help but we won't do your homework.
    Last edited by tenchu; 12-05-2010 at 08:41 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Homework
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 11-03-2001, 03:39 PM
  2. Homework
    By kermi3 in forum C Programming
    Replies: 10
    Last Post: 09-27-2001, 04:49 PM
  3. Homework
    By kermi3 in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2001, 03:16 PM
  4. Homework
    By kermi3 in forum C Programming
    Replies: 0
    Last Post: 09-10-2001, 01:26 PM

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