Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 03:43

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Unhandled Exception

Discussion on Unhandled Exception within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jan 2011
Posts: 862
Received Thanks: 404
Unhandled Exception

Hallo,
ich lerne gerade c++ und kriege einen Fehler in meinem Programm einfach nicht behoben.
Wenn ich danach frage ob man noch was Kaufen möchte Kommt eine Fehlermeldung. Wie kann ich das ändern?

code:
Code:
#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	string cAntwort;
	string sAuswahl[3];
	string sRechnung;
	
	int iAuswahl;
	int x = 0;
	float fKosten = 0;
	int iAnzahl = 0;


	do{
		int iAnzahl = 0;

		cout << "Sortiment:" << endl << "(1)Kartoffeln Kg	:1Euro" << endl
			<< "(2)Käse		:0,50Euro" << endl
			<< "(3)Wasser 		:0,70Euro" << endl;
		cout << "Was möchten sie Kaufen? " << endl;
		getline(cin, sAuswahl[x]);

		iAuswahl = stoi(sAuswahl[x]);


		
		switch (iAuswahl)
		{
		case 1:
			cout << "Wie viele Kg Kartoffeln möchten sie Kaufen?" << endl;
			cin >> iAnzahl;
			fKosten += 1 * iAnzahl;
			sRechnung += to_string(iAnzahl) + " Kartoffeln : " + to_string((float)iAnzahl * 1) + "Euro" +
				'\n';
			break;
		case 2:
			cout << "Wie viele Käse möchten sie Kaufen?" << endl;
			cin >> iAnzahl;
			fKosten += 1 * iAnzahl;
			sRechnung += to_string(iAnzahl) + " Käse : " + to_string((float)iAnzahl * .5) + "Euro" +
				'\n';
			break;
		case 3:
			cout << "Wie viele Wasser möchten sie Kaufen?" << endl;
			cin >> iAnzahl;
			fKosten += 1 * iAnzahl;
			sRechnung += to_string(iAnzahl) + " Wasser : " + to_string((float)iAnzahl * 0.7) + "Euro" +
				'\n';
			break;
		}
	

		x++;
		
		cout << "Darf es sonst noch was sein?(j/n)" << endl;
		cin.clear();
		cin >> cAntwort;
			
			

	} while ((cAntwort.compare("j") == 0|| cAntwort.compare("J") == 0) && x < 3 );

	//cout << sRechnung << endl;

	getchar();
	return 0;
}


mfg Önte
Önte is offline  
Old 07/30/2015, 17:29   #2
 
elite*gold: 0
Join Date: Oct 2007
Posts: 856
Received Thanks: 35
unhandled exception kommt vom stoi, ausserdem machst du es dir damit sowieso zu kompliziert wieso nicht einfach:
cin >> iAuswahl;

statt:

getline(cin, sAuswahl[x]);
iAuswahl = stoi(sAuswahl[x]);
Slade100 is offline  
Thanks
1 User
Old 07/30/2015, 20:43   #3
 
elite*gold: 0
Join Date: Jan 2011
Posts: 862
Received Thanks: 404
Danke es funktioniert jetzt. Ich habe keine Ahnung wie ich darauf gekommen bin *beschämt*
Önte is offline  
Reply


Similar Threads Similar Threads
Unhandled Exception: c00000005
12/03/2014 - Diablo 2 - 6 Replies
Hi all, I've just dl the D2NT and when i try to run it I am getting the error Unhandled Exception: c00000005. I can run the game normally it is only when I run the program when the problem happens. I've seen some answers to my problem in google, and I've tried to reinstall everything, reviewed my bot config and everything looks to be ok... can someone help me? I am using W7. Thanks!
C++ Unhandled exception at... [PROBLEM]
05/10/2014 - C/C++ - 3 Replies
How to fix? Help. http://s6.ifotos.pl/img/erorrpng_enephqq.png
MrFishIt - Unhandled exception
02/10/2013 - WoW Bots - 2 Replies
Hallo, ich würde gern nach einiger Zeit mal wieder angeln, dementsprechend kam MrFishIt mir gerade recht. Ich habe mich an alles gehalten: WoW32-Bit Client ist aktiviert, Microsoft Visual C++ 2010 Redistributable Package(x86) & Net. Framework 4.5 sind installiert. WoW + Bot als Admin gestartet und ingame das Häkchen bei DirectX 9 gesetzt. Allerdings bekomme ich, wenn ich anfangen will den Bot zu nutzen folgende Fehlermeldung (und wenige Sekunden später die Meldung, dass das Programm...
warrock.net down? [unhandled exception]
03/03/2011 - WarRock - 1 Replies
Hi bei mir kommt immer wenn ich auf warrock.net Code einlösen will unhandled exception
can anyone help with this unhandled exception?
03/21/2006 - Silkroad Online - 4 Replies
sro_client.exe(2160) - Unhandled Exception ACCESS_VIOLATION (0xc0000005) at address 0x10034a24 in module C:&#092;Documents and Settings&#092;user&#092;Desktop&#092;s robot&#092;Silk.dll(2006-03-19:10-10-54). Registers: EAX 00000028 EBX 0000000A ECX 10929118 EDX 0012FC56 ESI 0012FC50 EDI 10929118 CS:EIP 0000001B:10034A24 SS:ESP 00000023:0012FBF8 EBP 00000023 C:&#092;Documents and Settings&#092;user&#092;Desktop&#092;s robot&#092;Silk.dll at address: 10034a24 the sro_client.exe is 1,815,552 bytes



All times are GMT +1. The time now is 03:43.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.