 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Michael Pernkopf Guest
|
Posted: Wed Nov 12, 2003 8:06 pm Post subject: Wert von int 374berpr374fenn ^ |
|
|
Hy NG!
Ich habe folgende Frage bezüglich einer Variablen-Abfrage:
Ich lese in meinem Programm 2 Werte ein, und muß diese
Abfrage dann überprüfen, ob es Integer-Zahlen sind.
Gibts da in C++ eine Funktion?
lg, Michael
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
Kai Ruhnau Guest
|
Posted: Wed Nov 12, 2003 8:40 pm Post subject: Re: Wert von int 374berpr374fenn |
|
|
Michael Pernkopf wrote:
| Quote: | Hy NG!
Ich habe folgende Frage bezüglich einer Variablen-Abfrage:
Ich lese in meinem Programm 2 Werte ein, und muß diese
Abfrage dann überprüfen, ob es Integer-Zahlen sind.
Gibts da in C++ eine Funktion?
lg, Michael
|
#include <iostream>
int main()
{
int x1,x2;
if (!(std::cin>>x1))
std::cout<<"Fehler int 1n";
else if (!(std::cin>>x1))
std::cout<<"Fehler int 2n";
else
{
//x1 und x2 sind gültige int's
}
return 0;
}
Grüße
Kai
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
Kai Ruhnau Guest
|
Posted: Thu Nov 13, 2003 5:58 am Post subject: Re: Wert von int 374berpr374fenn |
|
|
Kai Ruhnau wrote:
| Quote: | Michael Pernkopf wrote:
Hy NG!
Ich habe folgende Frage bezüglich einer Variablen-Abfrage:
Ich lese in meinem Programm 2 Werte ein, und muß diese
Abfrage dann überprüfen, ob es Integer-Zahlen sind.
Gibts da in C++ eine Funktion?
lg, Michael
#include <iostream
int main()
{
int x1,x2;
if (!(std::cin>>x1))
std::cout<<"Fehler int 1n";
//else if (!(std::cin>>x1))
else if (!(std::cin>>x2)) //Hoppla...
std::cout<<"Fehler int 2n";
else
{
//x1 und x2 sind gültige int's
}
return 0;
}
|
Grüße
Kai
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
Michael Pernkopf Guest
|
Posted: Thu Nov 13, 2003 1:02 pm Post subject: Re: Wert von int 374berpr374fenn |
|
|
| Quote: |
Michael Pernkopf wrote:
|
[...]
| Quote: |
#include <iostream
int main()
{
int x1,x2;
if (!(std::cin>>x1))
std::cout<<"Fehler int 1n";
//else if (!(std::cin>>x1))
else if (!(std::cin>>x2)) //Hoppla...
std::cout<<"Fehler int 2n";
else
{
//x1 und x2 sind gültige int's
}
return 0;
}
|
Ich hab das mal nachgebastelt, und es hat zum gewünschten Ergebnis geführt.
Danke für deine schnelle Antwort
lg, Michael
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|