Toon posts:

[c++]afsluiten

Pagina: 1
Acties:
  • 37 views sinds 30-01-2008

Verwijderd

Topicstarter
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream.h>             
int main()                //Most important part of the program! 
{ 
  int age;                //Need a variable... 
  cout<<"Hoe oud ben je?: ";    //Asks for age 
  cin>>age;                //The input is put in age 
  if(age<100)                //If the age is less than 100 
  { 
     cout<<"Je bent nog heel erg jong!";     //Just to show it works 
  } 
  else if(age==100)        //I use else just to show an example 
  { 
     cout<<"Jij bent egt oud";        //Just to show you it works... 
  } 
  else 
  { 
    cout<<"oud!";    //Executed if no other statement is executed 
  } 
  return 0; 
}


kijk, als ik dit heb, of met andere code, dan kan je dus een leeftijd invoeren, maar zodra je op enter drukt, sluit de prog af?
weet iemand hoe ik dat kan oplossen?
want zo zie je bijvoorbeeld niet "Je bent nog heel erg jong" _/-\o_

  • ^Mo^
  • Registratie: Januari 2001
  • Laatst online: 04-11-2025
Draai je dit vanuit een IDE? Of vanuit de command line?
Zet anders eens cin.get() voor de laatste regel (return 0).... als je vanuit een IDE draait gaat het wellicht allemaal te snel...

"There are 10 kinds of people in the world, those who understand binary and those who don't" | Werkbak specs


Verwijderd

Verwijderd schreef op 05 maart 2004 @ 16:54:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream.h>             
int main()                //Most important part of the program! 
{ 
  int age;                //Need a variable... 
  cout<<"Hoe oud ben je?: ";    //Asks for age 
  cin>>age;                //The input is put in age 
  if(age<100)                //If the age is less than 100 
  { 
     cout<<"Je bent nog heel erg jong!";     //Just to show it works 
  } 
  else if(age==100)        //I use else just to show an example 
  { 
     cout<<"Jij bent egt oud";        //Just to show you it works... 
  } 
  else 
  { 
    cout<<"oud!";    //Executed if no other statement is executed 
  } 
  return 0; 
}


kijk, als ik dit heb, of met andere code, dan kan je dus een leeftijd invoeren, maar zodra je op enter drukt, sluit de prog af?
weet iemand hoe ik dat kan oplossen?
want zo zie je bijvoorbeeld niet "Je bent nog heel erg jong" _/-\o_
door boven return 0; cin.get(); toe te voegen.

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 12-05 22:23

curry684

left part of the evil twins

C++:
1
cin.get();

En koop een boek of volg even een online tutorial, dit is niet echt het niveau om een topic over te openen he :Y)

Professionele website nodig?


Dit topic is gesloten.