Visual C++ Console Applications

  • Thread starter Thread starter Ghada Ayed via DotNetMonster.com
  • Start date Start date
G

Ghada Ayed via DotNetMonster.com

Hi all,

I want to create an executable file of a C++ console application on Visual
Studio.Net 2005, that do not close immediately after ending the program (i.e.
similar to the option of Build->Start without degugging). so, I can
distribute the executable file.

Thanx
 
Ghada Ayed via DotNetMonster.com said:
Hi all,

I want to create an executable file of a C++ console application on Visual
Studio.Net 2005, that do not close immediately after ending the program
(i.e.
similar to the option of Build->Start without degugging). so, I can
distribute the executable file.

Thanx

Not sure why you're asking this in the C# group, the one you want is:

microsoft.public.dotnet.languages.vc

If you're asking how to get your C++ console app to pause with code,
something like this should do the trick (at the and of main():

cin.ignore(100,'\n'); // flush the input buffer
cout << "Hit enter to end the program.\n";
// program pauses here, waiting for input
char z = cin.get(); // get the keypress
 
/*****************************************************************/

well ...

I think it is a little depends on the logic of your program ... but here I
just will view a simple example ...

you can create an array of options as follows:
- options[0] = "quit"
- options[1] = "enter student recod"
- options[2] = "delete student record"
- options[3] = "view student record"
- options[4] = "edit student record" ....

then, you can create a while loop like the following one:

while (true)
{
// selected option by the user ...
int iOp = 0;

// print a message to the user ...
cout << "Select an option: ";

// read an option …
cin >> iOp;

If (iOp > 4 )
cout << endl << "Invalid option";
else
{
if( iOp == 1 )
{
// read the student id, name, faculty and year then save it into a file.
}
else if( iOp == 2 )
{
// read the student id, then remove it from a file.
}
else if( iOp == 3 )
{
// read the student id and print out all his/her information.
}
else if( iOp == 4 )
{
// read the student id, then print out all his/her information.
// print out a set of another options as follows ( as a while loop):
// [0] quit editing and save data.
// [1] cancel editing.
// [2] edit id.
// [3] edit name.
// [4] edit faculty
// [5] edit year
//

// ask the user to select one these options.
// based on the selected option, ask the user for the new id, name, faculty, or year.
}
else // it should be
{
exit (0);
}
}

} // end of while ...
/*****************************************************************/

I want to create an executable file of a C++ console application on Visual
Studio.Net 2005, that do not close immediately after ending the program (i.e.
similar to the option of Build->Start without degugging). so, I can
distribute the executable file.

Thanx

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-csharp/200704/1



___
Newsgroups brought to you courtesy of www.dotnetjohn.com
 
Back
Top