PDA

Click to See Complete Forum and Search --> : My exe has encountered a problem and needs to close


Illspirit
Nov 22nd, 2001, 01:29 PM
Calc.exe has encountered a problem and needs to close. We are sorry for the inconvenience.

I get this error running my small program.:confused: Nothing is picked up in the debugger, and i'm pretty sure its here in my code:


char c;

cout << "\nii) What do you want to do to " << a << "?\n\n";
cout << " A) Add something to it?\n";
cout << " B) Take something off it?\n";
cout << " C) Multiply it by something?\n";
cout << " D) Divide it by something?\n";
cout << " E) Find a percentage of it?\n";
cout << " F) Raise it to a power?\n";
cout << " G) Find the square root?\n";
cout << " H) Round it off?\n\n ";

cout << "-1-\n";
cin >> c;
cout << "-2-\n";




Here I get a "-1-", then input, then it gives me the error and NO "-2-" on the console:confused:

I'm new to c++ and i have no idea whats causing this
:confused:

Thanx for any help:)

filburt1
Nov 22nd, 2001, 01:36 PM
This works fine for me (BC++5):


#include <iostream.h>

int main()
{
char c;

char *a = "What should be here?";

cout << "\nii) What do you want to do to " << a << "?\n\n";
cout << " A) Add something to it?\n";
cout << " B) Take something off it?\n";
cout << " C) Multiply it by something?\n";
cout << " D) Divide it by something?\n";
cout << " E) Find a percentage of it?\n";
cout << " F) Raise it to a power?\n";
cout << " G) Find the square root?\n";
cout << " H) Round it off?\n\n ";

cout << "-1-\n";
cin >> c;
cout << "-2-\n";
return 0;
}

Illspirit
Nov 22nd, 2001, 01:53 PM
int main()
{

HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);

long FnRound ( long , long );
void StrAppend ( char [], char [], long, char* );
long vercin (long , long , char [] , char []);

char inputbuffer [] = "";
char* Bmessage = "";
char* ca = "";
char c;
long a = -1;
long b = -1;
int mode = 1;
int msgloop = 0;
bool exitloop = false;

const Gray = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
const bBlue = BACKGROUND_BLUE;


SetConsoleTextAttribute(h, bBlue | Gray);
system("cls");

cout << "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»\n";
cout << "º CALCULATOR º\n";
cout << "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ\n";

cout << "\n";

//SetConsoleTextAttribute(h, bBlue | Red);

//SELECT A


vercin (-9999, 9999, "Enter a number between -9999 and 9999", "Invalid Number");

cout << "\nii) What do you want to do to " << a << "?\n\n";

cout << " simple functions:\n";
cout << " A) Add something to it?\n";
cout << " B) Take something off it?\n";
cout << " C) Multiply it by something?\n";
cout << " D) Divide it by something?\n";

cout << " advanced functions:\n";
cout << " E) Add tax (17.55%) to it?\n";
cout << " F) Take tax (17.55%) off it?\n";
cout << " G) Find a percentage of it?\n";
cout << " H) Raise it to a power?\n";
cout << " I) Find the square root?\n";
cout << " J) Round it off?\n\n ";

cout << "-1-\n";
cin >> c;
cout << "-2-\n";
cout << "\n";




//SELECT OPERATION - SIMPLE
if (c == 'A')
{
StrAppend ("iii) Ok, add what to " ,"??\n ", a , Bmessage);
mode = 1;
}
else if (c == 'B')
{
StrAppend ("iii) Ok, take what off " ,"??\n ", a, Bmessage);
mode = 2;
}
else if (c == 'C')
{
StrAppend ("iii) Ok, multiply what by " ,"??\n ", a, Bmessage);
mode = 3;
}
else if (c == 'D')
{
StrAppend ("iii) Ok, divide " ," by what??\n ", a, Bmessage);
mode = 4;
}
else if (c == 'a')
{
StrAppend ("iii) Ok, add what to " ,"??\n ", a, Bmessage);
mode = 1;
}
else if (c == 'b')
{
StrAppend ("iii) Ok, take what off " ,"??\n ", a, Bmessage);
mode = 2;
}
else if (c == 'c')
{
StrAppend ("iii) Ok, multply what by " ,"??\n ", a, Bmessage);
mode = 3;
}
else if (c == 'd')
{
StrAppend ("iii) Ok, divide " ," by what??\n ", a, Bmessage);
mode = 4;
}

//SELECT OPERATION - ADVANCED
else if (c == 'E')
{
mode = 5;
}
else if (c == 'F')
{
mode = 6;
}
else if (c == 'G')
{
StrAppend ("iii) Ok, find what percentage of " ,"??\n ", a, Bmessage);
mode = 7;
}
else if (c == 'H')
{
StrAppend ("iii) Ok, raise " ," to what power??\n ", a, Bmessage);
mode = 8;
}
else if (c == 'I')
{

mode = 9;
}
else if (c == 'e')
{
mode = 5;
}
else if (c == 'f')
{
mode = 6;
}
else if (c == 'g')
{

StrAppend ("iii) Ok, find what percentage of " ,"??\n ", a, Bmessage);
mode = 7;
}
else if (c == 'h')
{
StrAppend ("iii) Ok, raise " ," to what power??\n ", a, Bmessage);
mode = 8;
}
else if (c == 'i')
{
mode = 9;
}
else
{
cout << "Sorry, your retardedness has gotten the better of you, \n" << c <<" wasn't one of the choices." << "\n";
cout << "Better luck next time." << "\n";
mode = 0;
}




long vercin ( long minval , long maxval , char firstmessage [] , char secondmessage [] )
{

long buffer = 0;
bool accept = false;

do
{



cout << firstmessage << "\n";
cin >> buffer;

if (buffer <= minval)
{accept = false;}

else if (buffer >= maxval)
{accept = false;}

else
{accept = true;}

if (accept == true)
{}

else
{cout << secondmessage << "\n";}



} while (accept == false);

return buffer;

}



void StrAppend ( char stringA [], char stringB [], long longA, char* strOut )
{

char ReturnStr [] = "";
char ConvLong [] = "";

itoa( longA, ConvLong , 10 );

strcpy(ReturnStr , stringA);

strcat( ReturnStr, ConvLong );
strcat( ReturnStr , stringB );


strOut = ReturnStr;

}