Jump to content

Question about console programmin

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Danerd100

Danerd100

    Learning Programmer

  • Members
  • PipPipPip
  • 52 posts
Okay, I have written programs using dev-c++ with the console programming part. The problem is that the kill command is ENTER, so when I ask for a variable, I type it, and I hit ENTER, to input it, it kills the application, I was wondering if there was a way to change the kill command

#2
mokszyk

mokszyk

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
please paste the code, then maybe i will help you
THink positive :)

#3
Danerd100

Danerd100

    Learning Programmer

  • Members
  • PipPipPip
  • 52 posts
Here is an example of the code
[HIGHLIGHT="C++"]#include <iostream>

using namespace std;

int main ()
{
string Name;
cout << "What Is Your Name?" << endl;
cin >> Name;
cout << "Hi" << Name;
return 0;
}
[/HIGHLIGHT]

But it doesn't work, no matter how I make it, anytime I prompt for something, it closes when i press enter to submit it

#4
mokszyk

mokszyk

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
hmm :) it's simple
after 10 line insert
system("pause"); // after it there is return 0; 

example
[highlight="c++"]#include <iostream>
using namespace std;
int main ()
{
string Name;
cout << "What Is Your Name?" << endl;
cin >> Name;
cout << "Hi " << Name << endl; // i added new line
system("pause"); // added this option
return 0;
}
[/highlight]
THink positive :)

#5
Danerd100

Danerd100

    Learning Programmer

  • Members
  • PipPipPip
  • 52 posts
Thank you very much, it works now