Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Questions, pls come in
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kk01




PostPosted: Sat May 19, 2012 9:59 pm   Post subject: Questions, pls come in

I am using Dev-Cpp software. I have the following program. When I compile the program, the screen just pop-out and close instantaneously. I am confused and I think there must be an error in the do while loop since userInput was not set with a value. But, it still doesn't work. At least, at this point, I expect the welcome screen (Welcome to Database!) will show up. It doesn't work at all Can anyone help me with this? Thanks a lot Smile)

c++:

int main ()
{
        int number; // create a variable to store user designated #
        string userInput; // create a variable to store user instruction
        cout << "Welcome to Database! \n";
        helpMe();
        cout << "\n";
    do
        {
                cout << "Instructions? "; // ask user for instruction
                cin >> userInput; // get userInput
                if (userInput=="new") // if userInput is new
                {
                        cout << "Create a new reocrd at? "; // ask user for number they wish to create
                        cin >> number; // get newNum
                        newRecord(number); // call newRecord function
                }
                else if (userInput=="help") // if userInput is help
                {
                        helpMe(); // call helpMe function
                }
                else if (userInput=="edit")// if userInput is edit
                {
                        editRecord(); // call editRecord function
                }
                else if (userInput=="delete") // if userInput is delete
                {
                        deleteRecord(); // call deleteRecord function
                }
                else if (userInput=="save") // if userINput is save
                {
                        saveRecord(); // call saveRecord function
                }
                else if (userInput=="load") // if userInput is load
                {
                        loadRecord(); // call loadRecord function
                }
                else if (userInput=="sort") // if userInput is sort
                {
                        sortRecord(); // call sortRecord function
                }
                else if (userInput=="search") // if userInput is search
                {
                        searchRecord(); // call searhRecord
                }
        }
        while(userInput!="stop"); // exit the loop when userInput is stop, otherwise, continue
        cout << "\n";
        system ("PAUSE");
}


-

Next time please wrap your code in

code:

[syntax="cpp"]
...
[/syntax]


in order to preserve whitespace and add colours and stuff.
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Sun May 20, 2012 6:06 pm   Post subject: RE:Questions, pls come in

"Compile" and "Run" are different things. Running your program requires that it be compiled; compiling just means converting your C++ code to something the computer understands.

Try finding a "Run" or "Debug" button or menu-entry to click on.
kk01




PostPosted: Sun May 20, 2012 10:10 pm   Post subject: Re: Questions, pls come in

well, I press "compile and run", the problem is still the same.
QuantumPhysics




PostPosted: Tue May 22, 2012 3:39 pm   Post subject: RE:Questions, pls come in

you have the helpme() function... but where did you state what it does... all the computer see's is a blank canvas. use Console.System("pause")
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: