just started

S

sterling.mckay

Just started to teach myself C C++ programming... I have been very
interested with computers for a while now and have a nac or so I
thought for how they work ... hardware I am ok with ... I can
understand and tear it down and rebuild it ... chips boards I/O etc
etc ... programing is a different beast ...

So I am fooling around with C and compile a small .exe file with
Miracle C ... simple thing that said Hi my name is etc etc ... but I
noticed that it loads in a dos window ... Why doesn't it load in
a .txt file ? My main question is this ... after you run the test.exe
it flashes open the DOS window and closes quickly ... now this I
understand ... I do have my MCE and I am trained in Windows XP tech
support ... I know that a "close on exit" command is "checked" for the
application and I know to just open the default properties and de-
select the check box ...

My question is this ... is there a way in C or C++ to write this into
the test.exe I made that simply shows "my name is .... "

This is where I am a total newb and have no idea where to go ... I
don't see any reference to a switch or execute in any of the library
files ... the stdio.h or stdlib.h ... i don't see where i can say

the directory is C:\windir
the program is C:\windir\default
the program has a properties tab
the properties tab has Misc, etc etc ...
the misc tab has an option for "close on exit"
the "close on exit" should be false

I have no idea really ... i don't even know if it possible ... maybe
it's better to just reg hack it and save the batch file ...

Any ideas ? or I am way the hell off base ? :) !
 
I

Ian Collins

So I am fooling around with C and compile a small .exe file with
Miracle C ... simple thing that said Hi my name is etc etc ... but I
noticed that it loads in a dos window ... Why doesn't it load in
a .txt file ? My main question is this ... after you run the test.exe
it flashes open the DOS window and closes quickly ... now this I
understand ... I do have my MCE and I am trained in Windows XP tech
support ... I know that a "close on exit" command is "checked" for the
application and I know to just open the default properties and de-
select the check box ...
Looks like you'd be better of posting to a windows programming group, or
one for your compiler.
 
L

LoKi

The simplest way to keep the DOS window from closing automatically is
to use the following command:

system("pause");

place this command just before the return 0; in your main function.


this will issue a pause command to the terminal and will wait until
input to continue.
(I'm not sure i fully understand your questions...so I apologize if
this is completely off topic.)
 
S

sterling.mckay

lol I am not sure I fully understand the questions either :)
I am curious about programming and wanted to see what and where to
start ... so I got some info on C C++ and then made a simple file ...
set some varibles etc ...

but when I noticed that the dos window open and closed instantly I was
again just curious ... I mean in windows all I had to do was go to c:
\windir\default and choose the properties and deselect the check box
to close on exit ... and then started to wonder if I could incorperate
this into the script with C C++ commands ...

maybe I need to look into Visual C++ to interact with Windows ...
again I am not sure just curious is all


The simplest way to keep the DOS window from closing automatically is
to use the following command:

system("pause");

place this command just before the return 0; in your main function.

this will issue a pause command to the terminal and will wait until
input to continue.
(I'm not sure i fully understand your questions...so I apologize if
this is completely off topic.)

(e-mail address removed) wrote:
one for your compiler.
 
L

LoKi

try running this code:


#include <iostream>
using namespace std;

int main()
{
cout << "Hi my name is John Doe" << endl;

cout << '\n';
system("pause"); //this command is used to pause the terminal window
return 0;
}
 
S

sterling.mckay

Ok so ... please understand that I am completely new at this and I am
learning as I go ... I have read page after page but I learn when I am
testing stuff and actually doing/trying things out.

That code will not compile in the Miracle C application that I dl'ed
for testing ... so does that mean that I need a different compiler ?
if so what is a good one to start with ?
 
S

sterling.mckay

nice ... thanks for the heads up on this compiler ... I'll do some
research on it and see what I can see :) Thanks again bro !! If you
have any fav news groups or sites with info that could help a new guy
out lemme know.

/salute
 
A

Alf P. Steinbach

* (e-mail address removed):
Just started to teach myself C C++ programming... I have been very
interested with computers for a while now and have a nac or so I
thought for how they work ... hardware I am ok with ... I can
understand and tear it down and rebuild it ... chips boards I/O etc
etc ... programing is a different beast ...

So I am fooling around with C and compile a small .exe file with
Miracle C ... simple thing that said Hi my name is etc etc ... but I
noticed that it loads in a dos window ... Why doesn't it load in
a .txt file ? My main question is this ... after you run the test.exe
it flashes open the DOS window and closes quickly ... now this I
understand ... I do have my MCE and I am trained in Windows XP tech
support ... I know that a "close on exit" command is "checked" for the
application and I know to just open the default properties and de-
select the check box ...

My question is this ... is there a way in C or C++ to write this into
the test.exe I made that simply shows "my name is .... "

This is where I am a total newb and have no idea where to go ... I
don't see any reference to a switch or execute in any of the library
files ... the stdio.h or stdlib.h ... i don't see where i can say

the directory is C:\windir
the program is C:\windir\default
the program has a properties tab
the properties tab has Misc, etc etc ...
the misc tab has an option for "close on exit"
the "close on exit" should be false

I have no idea really ... i don't even know if it possible ... maybe
it's better to just reg hack it and save the batch file ...

Any ideas ? or I am way the hell off base ? :) !

First, please don't top-post in this group, as you've done later in the
thread.

Your question really has nothing to do with C++. You'll get the same
effect no matter which language is used to create your executable. It's
purely a Windows issue.

Normally that would be off-topic, but this issue is so common that it
would be evil to send you somewhere else.

So: you can (1) use a command interpreter to run your program (there is
a primitive one shipped with Windows), (2) make a simple batch file to
run your program and pause, (3) use an Integrated Development
Environment that does the batch file thing for you automatically, (4)
make your program itself pause at the end, e.g. by reading a line from
standard input, or (5) use some other operating system than Windows.

The best option is (1), because you'll need to learn to use the computer
that way anyway, and the worst option, because it requires learning a
whole new operating system, is (5).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top