Thread: Problem with code. Need advice.

  1. #1
    Registered User
    Join Date
    May 2011

    Question Problem with code. Need advice.

    I have an issue with some basic code I've been writing to learn C++. I've posted it here with comments. I'm using Code::Blocks, if that helps, and if the formatting doesn't come out right in the post, you should be able to copy and paste it to a maximized notepad file to get the formatting right. Otherwise, I'll attach a .txt file to this post. Take your pick.

    //This is a nonsensical program for me to practice various aspects of the C++ Language. It should
    //have a very simple conversation with the user. However, when I attempt to compile the program, I
    //get several error messages stating (for example):
    //  "error: too few arguments to function 'void DayMessage(std::string, std::string)'"
    //Please help me understand where I am going wrong, as I have looked over the code and cannot
    //understand the errors. Thank you. Replies can be posted here or sent to
    #include <iostream>
    using namespace std;
    //Just a simple function usage. Extraneous, I know, but my first self-created function.
    void HelloThere()
        cout<<"\n\nWell, hello there!\n\n";
    //Not extraneous. Should get a carriage return to pass to void PrgmEnd()
    void GetBreakCmd()
            string BreakCmd="a"; //Initializes BreakCmd to 'a' so that Return must be pressed.
            cout<<"\n\n\nPlease press Return (Enter) to close.";
    //First instance of the above stated error. Should pass BreakCmd to the function, and if matching,
    //close down the program. Otherwise, it should repeat the prompt to press enter to close.
    void PrgmEnd(string BreakCmd)
         if (BreakCmd == "")//In other words, if Return (Enter) was pressed
            //Should exit the function and return to main, ending the program and closing the window.
            GetBreakCmd(); //Go back and repeat the prompt
    //The next instance of the error. This function should test the string DayOfWeek, and output a
    //message based on the input. Doesn't have an error catcher for entries that are not days of the
    //week yet. Also likely has several other errors. Sorry, I know, but I was going to start debugging
    //when I hit this snag.
    void DayMessage (string DayOfWeek , string Name)
                if (DayOfWeek == "Friday")
                    cout<<"\nIt's Friday? Yay! That means it's payday!\n\n";
                else if (DayOfWeek == "Saturday" || DayOfWeek == "Sunday")
                    cout<<"\nAh, that's right! Payday was just here!\n\n";
                    cout<<"\nDarn! It's not Friday... I guess payday isn't here yet.\n\n";
                  cout<<"Anyway, "<<Name<<", I'm feeling pretty tired. I'm going to go to sleep now.\n\nGoodbye, "<<Name<<"!\n";
    int main()
        //Declares and initializes the two variables Name and DayOfWeek
        string Name="";
        string DayOfWeek="";
        //Executes that first simple function
        //Prompt for the user's name
        cout<<"\nWhat is your name?\n\n> ";
        //Response and prompt for the day of the week
        cout<<"\nHello, "<<Name<<"! What day is today?\n\n> ";
        //Should rund DayMessage based on the entry for DayOfWeek
        //Should prompt and get the program close sequence
        //If program close sequence is executed, should finish out the main function and close the
        //Returns a 0. I know there's probably a different way of doing this, but this is how I've
        //learned so far. Any hints, tips, tricks, otherwise would be appreciated. I'm a greenhorn
        //programmer and willing to learn if you're willing to offer advice.
    	return 0;
    //Thanks again for the help. Again, replies can be posted here or emailed to me at
    Thanks again,

    Attached Files Attached Files
    Last edited by sdaniels1288; 05-31-2011 at 04:37 AM. Reason: Forgot to add the attachment

  2. #2
    Join Date
    Aug 2010
    Ontario Canada
       //Should rund DayMessage based on the entry for DayOfWeek
    Look at your function definition... it wants two strings, DayOfWeek and Name...

    C++ is smart but it's not a mind reader...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need advice to solve a problem
    By HAssan in forum C Programming
    Replies: 3
    Last Post: 08-06-2009, 02:57 AM
  2. Advice sought on GUI library / tools / code
    By PaulBlay in forum C++ Programming
    Replies: 7
    Last Post: 06-03-2009, 04:20 AM
  3. Looking for a Code Management System. Advice needed.
    By Kempelen in forum Windows Programming
    Replies: 0
    Last Post: 04-23-2009, 11:06 AM
  4. Advice requested, Code makes sense to me, not compiler
    By andrew.bolster in forum C Programming
    Replies: 53
    Last Post: 01-06-2008, 01:44 PM
  5. Problem with this code
    By miclus in forum C++ Programming
    Replies: 9
    Last Post: 09-01-2004, 09:15 PM
Website Security Test