Visual basics run without debugging

Hi i have a certain console app and whenever i type in the wrong answer it auto closes but when i run without debugging it asks me to press i button before closing i was wondering if there was anyway to make an .exe file start without debugging other wise it just auto closes
If this subject is Visual Basic related, I recommend not to post this subject here. And besides, if you have a problem like that, we need more information; what does you code look like for example. How is the build configured? What are you using as your IDE?

Please elaborate.
Last edited on
here's the code


// dragons.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
int Choice;

printf( "Welcome to Shaun Ripper's Epic Adventure Saga.\n" );
printf( "You will be placed in the life of shador the great. ENJOY!\n" );
printf( "The Story so Far........\n" );
printf( "It is the dark ages, the knight saga when dragons and magicians still lived.\n" );
printf( "As there was once a protector named Shador the dragon knight who lived in " );
printf( "in the castle of Olon.\n" );
printf( "Shador saved Olon from many arising threats until the day Havenger rose.\n" );
printf( "He used magic to stun shador by surprise in the air. Shador fell out of " );
printf( "sky and was never seen again. Havenger was immediately exicuted for his " );
printf( "crimes leaving Olon to grave danger." );
printf( " But Havenger arose from the nether world with an army of dragons.\n" );
printf( "Luckily the savior of Olon wasn't dead although " );
printf( "Shador has lost his past memories as a dragon knight and other memories.\n" );
printf( "Will he recoop in time to save Olon!" );

printf( "\n\nYou wake in a mysterious dungeon.\n" );
printf( "Deep wounds are apparent on your body.\n" );
printf( "You stand up it's long and dark and a light at the end.\n" );
printf( "You start to hobble out to the light, a vast world awates you.\n" );

printf( "\ninput 1 to survey your surroundings at the light.\n" );
printf( "input 2 to jump when reached light.\n" );
printf( "\n" );

printf( "Choose wisely.\n" );
scanf( "%d", &Choice );

if( Choice == 1 )
{
printf( "North, a castle in flames with a dragon above.\n" );
printf( "East, utterly dense forest.\n" );
printf( "West, utterly dense forest.\n" );
printf( "South, the dark dungeon you came from.\n" );
printf( "But below is a large cliff that you could easily fall of on.\n" );
}
else if( Choice == 2 )
{
printf( "Whilst jumping you dont land and fall to your death.\n" );
return(0);
}
else
{
printf( "You stand pondering your for to long and get swooped by a dragon.\n" );
return(0);
}

printf( "You see an easily scaleable side, but how will get you there!\n" );

printf( "\ninput 1 if you want to jump for the destination.\n" );
printf( "input 2 if you want to scale the cliff side.\n" );

printf( "Choose wisely.\n" );
scanf( "%d", &Choice );

if( Choice == 1 )
{
printf( "You take a short run up and leap luckily you just make the distance.\n" );
}
else if( Choice == 2 )
{
printf( "You slowly edge your way on a thin rock surface and slip to a falling death.\n" );
return(0);
}
else
{
printf( "You stand hesitating and then the ground before you crumbles.\n" );
return(0);
}

printf( "You uneasily scale down the rocky slope and at the bottom you reach 3 pathways.\n" );
printf( "Path 1.Forest, Path 2.Castle, Path 3.Forest" );

printf( "\n\ninput 1 to follow path 1.\n" );
printf( "input 2 to follow path 2.\n" );
printf( "input 3 to follow path 3\n" );

printf( "Choose wisely.\n" );
scanf( "%d", &Choice );

if( Choice == 1 )
{
printf( "You leisurely stroll through the forest and once deep loosing the pathway.\n" );
printf( "Your lost, scared, hungry you eventually die by a vigerous pack of wolves.\n" );
return(0);
}
else if( Choice == 2 )
{
printf( "You walk in the shadows trying to avoid the dragon.\n" );
printf( "When suddenly you are grabbed and pulled into secret village.\n" );
}
else if( Choice == 3 )
{
printf( "You leisurely stroll through the forest and once deep loosing the pathway.\n" );
printf( "Your lost, scared, hungry you eventually die by a vigerous pack of wolves.\n" );
return(0);
}
else
{
printf( "Trying to organise your thoughts the dragon you spotted earlier\n" );
printf( "spots you burns you to death.\n" );
return(0);
}

printf( "To your surprise this was a doctor who is trying to protect you from the dragon.\n" );
printf( "He examines your wounds and takes you to his hut for healing, unvieling a tatoo.\n" );
printf( "The doctor recognised this straight away and informed the town gypsy.\n" );
printf( "You are deeply puzzeled but decide to play along.\n" );
printf( "Entering the gypsy tent she gives you a look of mystery and says.\n" );
printf( "'Get out of my sight you grotty man.'\n" );

printf( "\ninput 1 to hit the gypsy for offending you.\n" );
printf( "input 2 to sit down plead to the gypsy for help.\n" );
printf( "Choose wisely.\n" );

scanf( "%d", &Choice );

if( Choice == 1 )
{
printf( "After hitting her you immediately regret it as guards storm through the tent.\n" );
printf( "and impale you with their swords as you are thought to be an intruder.\n" );
return(0);
}
else if( Choice == 2 )
{
printf( "You immediatly show The gypsy your tatoo and she turns gobsmacked.\n" );
printf( "She utters out 'Th, th the savior is back THE DRAGON KNIGHT HAS RETURNED.\n" );
}
else
{
printf( "You stand there like a dummy in your own world ignoring the gypsy totally.\n" );
printf( "She calls the guards. The guards come and throw you out in the dragons " );
printf( "firing zone you are immediately incinerated.\n" );
return(0);
}

printf( "\nYou sit and listen you tell the gypsy you have to memories at all.\n" );
printf( "She tells you everything. She starts, 'Your name is Shador you were once the " );
printf( "great savior of this land and protector. Until the day you were banished from " );
printf( "Olon castle then Havenger rose from the nether and leads the dragon army.\n" );
printf( "Your our only hope Shador.'\n" );
return 0;
}

OK, this looks more promising. I guess you want to wait for input after wrong decision in your application. This goal can be achieved in various ways, but what I recommend is this:

1
2
3
#include <iostream>

std::cin.get(); // Get input. 


By the way, is your application C++ compatible? I see you are using printf-function, which is standard C output function. It is OK, if you want to optimize your code for maximum speed, but maybe you are looking after the overall functionality by now, right? So please prefer C++ standard library whenever possible. It is more flexible and less error-prone.

Does this help?
Last edited on
so if i put std::cin.get(); after all my returns it will stop from quitting each time i get the wrong answer
Last edited on
Yes, but you must be cautious with it's placement. Allow me to demostrate.

If you create a code like this...
1
2
return 0;
std::cin.get();


...std::cin.get() will not be called. This is because return-statement will exit current function immediatly. All statements after return-statement will be ignored. So, if you want to get input before exiting, do it another way around:
1
2
std::cin.get();
return 0;


Your code needs more tuning, but I think this solves your problem. If you keep going forward in learning programming, you realize more handsome solutions. But for now, have fun programming!

PS: Remember to put your code into code block(s) like this in the future. That way it is easier to read and you get better & faster solutions.
Last edited on
Thankyou for your help
Topic archived. No new replies allowed.