I just want the programme to stop for a while.
Thanks. 38 4017
"Jackie" writes: I just want the programme to stop for a while.
Your best bet is probably the system() function since
it lets you interact with the OS. For example, in Windows, try
system("pause") ;
Jackie wrote: I just want the programme to stop for a while. Thanks.
Do you want the program to stop until you hit enter? If so, use cin like:
string str;
cin >> str;
That will stop the program till you press the Enter key.
Alvin
On Sun, 29 Jan 2006 08:43:57 -0800, "osmium" <r1********@com cast.net>
wrote: "Jackie" writes:
I just want the programme to stop for a while.
Your best bet is probably the system() function since it lets you interact with the OS. For example, in Windows, try system("pause" );
In C type logic ... I create a dummy string and use gets() to pause a
program.
#include <stdio.h>
char junk[81];
printf("routine _name(%d):"
" hit return to continue the paused program ...\n", __LINE__);
gets(junk);
-----------------
gets(junk); is good for clearing erroneous key strokes before
prompting for keyboard input in programs as well.
If erroneous keystrokes occur and the pause is critical ... you should
test for a null string. The following echos the erroneous keystrokes:
if(junk[0])
{
printf("routine _name(%d): junk = %s\n", __LINE__, junk);
gets(junk);
}
The "__LINE__" macro tells you the exact line and by including the
name of the routine in your printf statement you can find this pause
point easily.
Setting a break point would work too. But I usually don't debug using
break points. I like print statements. I often write them to log files
and turn the pause feature on and off with a #define.
#define pause 1
if(pause) gets(junk);
My apologies for not having sufficient C++ skills to make the code
clean and gorgeous. Fortunately C is fully supported in C++. My bet is
a C++ guru in here will teach us both a better way. :))
Tom wrote: On Sun, 29 Jan 2006 08:43:57 -0800, "osmium" <r1********@com cast.net> wrote:
"Jackie" writes:
I just want the programme to stop for a while. Your best bet is probably the system() function since it lets you interact with the OS. For example, in Windows, try system("pause") ;
In C type logic ... I create a dummy string and use gets() to pause a program.
#include <stdio.h>
char junk[81]; printf("routine _name(%d):" " hit return to continue the paused program ...\n", __LINE__); gets(junk);
That is a *HUGE* security risk. What if I type more than 80 characters?
I suddely make your program _read my input_ into the memory that wasn't
designated for it.
-----------------
gets(junk); is good [..]
No! It's _awful_. Never use it. NEVER!
V
Alvin wrote: Jackie wrote:
I just want the programme to stop for a while. Thanks.
Do you want the program to stop until you hit enter? If so, use cin like:
string str; cin >> str;
That will stop the program till you press the Enter key.
No, not really. Try it yourself. It will stop the program
till you press _something_ and then the Enter key.
- J.
On Sun, 29 Jan 2006 14:39:45 -0500, "Victor Bazarov"
<v.********@com Acast.net> wrote: Tom wrote: On Sun, 29 Jan 2006 08:43:57 -0800, "osmium" <r1********@com cast.net> wrote:
"Jackie" writes:
I just want the programme to stop for a while.
Your best bet is probably the system() function since it lets you interact with the OS. For example, in Windows, try system("pause") ;
In C type logic ... I create a dummy string and use gets() to pause a program.
#include <stdio.h>
char junk[81]; printf("routine _name(%d):" " hit return to continue the paused program ...\n", __LINE__); gets(junk);
That is a *HUGE* security risk. What if I type more than 80 characters? I suddely make your program _read my input_ into the memory that wasn't designated for it.
-----------------
gets(junk); is good [..]
No! It's _awful_. Never use it. NEVER!
V
Victor --
I believe you missed the "erroneous" part of the discussion?
The method I proposed is one I have used for years and was learned
from a C textbook. Typically I set the size of junk[] to 240
characters and use it for all types of input and output. But how do
you justify that size without other usages?
Check out the Microsoft help on gets(). You will see they use a size
of 81 for that example.
If you "get" 80 characters from a erroneous pool of xxxx characters
.... what remains is (xxxx - 80) erroneous characters. I suppose those
erroneous characters are a *HUGE* security risk and they are _awful_
too. Perhaps we should destroy all computers ... the risk is just
great for mankind.
I took the effort to read several of your replies. Your knowledge of
C++ is light years beyond mine as easily observed; however, you seem
to have made yourself a self appointed cop in the group?
And your preferred solution to the original question is .... ???
Please impress me with "how" to do things better and quit slamming
folks for existing outside your definition of intelligence. Go ahead,
teach me! I can learn from you. And just maybe ... you can learn a
thing or two as well?
-- Tom
Tom wrote: On Sun, 29 Jan 2006 14:39:45 -0500, "Victor Bazarov" <v.********@com Acast.net> wrote:
Tom wrote: On Sun, 29 Jan 2006 08:43:57 -0800, "osmium" <r1********@com cast.net> wrote:
"Jackie" writes:
> I just want the programme to stop for a while. Your best bet is probably the system() function since it lets you interact with the OS. For example, in Windows, try system("pause") ;
In C type logic ... I create a dummy string and use gets() to pause a program.
#include <stdio.h>
char junk[81]; printf("routine _name(%d):" " hit return to continue the paused program ...\n", __LINE__); gets(junk);
That is a *HUGE* security risk. What if I type more than 80 characters? I suddely make your program _read my input_ into the memory that wasn't designated for it.
-----------------
gets(junk); is good [..] No! It's _awful_. Never use it. NEVER!
V
Victor --
I believe you missed the "erroneous" part of the discussion? The method I proposed is one I have used for years and was learned from a C textbook. Typically I set the size of junk[] to 240 characters and use it for all types of input and output. But how do you justify that size without other usages?
Check out the Microsoft help on gets(). You will see they use a size of 81 for that example.
If you "get" 80 characters from a erroneous pool of xxxx characters ... what remains is (xxxx - 80) erroneous characters. I suppose those erroneous characters are a *HUGE* security risk and they are _awful_ too. Perhaps we should destroy all computers ... the risk is just great for mankind.
I took the effort to read several of your replies. Your knowledge of C++ is light years beyond mine as easily observed; however, you seem to have made yourself a self appointed cop in the group?
And your preferred solution to the original question is .... ???
Please impress me with "how" to do things better and quit slamming folks for existing outside your definition of intelligence. Go ahead, teach me! I can learn from you. And just maybe ... you can learn a thing or two as well?
-- Tom
For what its worth, I second this.
V - take a few deep breaths before you fire off next time. Proficiency
in C++ does not entitle you to bad manners.
--dakka
Tom wrote: On Sun, 29 Jan 2006 14:39:45 -0500, "Victor Bazarov" <v.********@com Acast.net> wrote:
Tom wrote: char junk[81]; printf("routine _name(%d):" " hit return to continue the paused program ...\n", __LINE__); gets(junk); That is a *HUGE* security risk. What if I type more than 80 characters? I suddely make your program _read my input_ into the memory that wasn't designated for it.
I believe you missed the "erroneous" part of the discussion?
No, you just missed the point. He's right, it's an enormous security
risk and it's awful. You need to spend less time being defensive and
more time worrying about writing correct code.
The method I proposed is one I have used for years and was learned from a C textbook.
Marvelous. It's wrong.
If you "get" 80 characters from a erroneous pool of xxxx characters ... what remains is (xxxx - 80) erroneous characters. I suppose those erroneous characters are a *HUGE* security risk and they are _awful_ too. Perhaps we should destroy all computers ... the risk is just great for mankind.
Uh, are you seriously not familiar with the concept of a buffer
overflow? You allocate an array of 80 characters, then pass that array
(as a pointer) to a function which will read in as many characters as
the user cares to type. The 81st character clobbers some random chunk
of memory, and you get undefined behavior; in many cases, this is an
easy security exploit.
I took the effort to read several of your replies. Your knowledge of C++ is light years beyond mine as easily observed; however, you seem to have made yourself a self appointed cop in the group?
Warning people not to heed dangerous and incorrect advice is a good
thing. Why is this personal for you?
Please impress me with "how" to do things better and quit slamming folks for existing outside your definition of intelligence.
Nobody slammed you. The dangerous and ill-founded recommendation you
voiced received a well-deserved thrashing, but that, again, is a good
thing.
Go ahead, teach me! I can learn from you. And just maybe ... you can learn a thing or two as well?
Enough melodrama. This is a technical newsgroup, please make sound
technical arguments. Nobody's convinced of anything by hissy fits.
Luke
"Jacek Dziedzic" <jacek@no_spam. tygrys.no_spam. net> wrote in message
news:56******** *************** ****@news.chell o.pl... Alvin wrote: Jackie wrote:
I just want the programme to stop for a while. Thanks.
Do you want the program to stop until you hit enter? If so, use cin like:
string str; cin >> str;
That will stop the program till you press the Enter key.
No, not really. Try it yourself. It will stop the program till you press _something_ and then the Enter key.
- J.
This is what I also use, std::cin >> str;
but if you are not worried about platform compatability you could use
whatever your compiler allows to see if a key has been pressed. I know that
microsoft compilers generally have a kbhit used like:
while ( !kbhit() );
I've always wished this to be part of the standard cause it's just so
useful. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew |
last post by:
When will .NET have a low-pause-time garbage collector
A low-pause-time garbage collector would greatly improve .NET's ability to serve as a platform for soft real-time systems. It doesn't have to be perfect. For example, I'd be happy with something where there was at most one pause per second, each pause was less than .2 seconds, and half the process's memory was inaccessible to the application due to garbage collection management
It...
|
by: hplloyd |
last post by:
Hi i want my VB.NEt application to run a seperate application from the command line, and then wait until this application has completed before continuing
I am currently using
System.Diagnostics.Process.Start(strApp) where strApp is the command line but this simply starts a new process... I want the command to be run as part of the existing process...
Any ideas?
|
by: tripyre |
last post by:
I recently resolved an issue I had with passing a variable to a call
shell command, but now I need it to pause or leave the window open so I
can manually close it. Below is my code, and I am not sure where to
begin to keep the DOS window from closing.
Dim stAppName As String
Dim stIPAddress As String
stAppName = "C:\WINDOWS\system32\ping.exe "
stIPAddress =
|
by: Edd Dawson |
last post by:
Hi. I have a strange problem involving the passing of command line
arguments to a C program I'm writing. I tried posting this in
comp.programming yesterday but someone kindly suggested that I'd have
better luck here. So here goes!
My program ignores any command line arguments, or at least it's
supposed to. However, when I pass any command line arguments to the
program, the behaviour of one of the functions changes mysteriously. I
have...
|
by: Wim |
last post by:
My GUI application starts a process (a console program) when the user
hits Play. I would like to add an option to pause that process. The
code I've added to detect if the user hit pause/unpause seems to work.
But I have no clue how to pause/suspend the process. As far as I can
see the Process class doesn't offer anything for this. So it's probably
the thread the process is running on that should be suspended or put to
sleep. But just...
| |
by: Trint Smith |
last post by:
I need to pause one second here-|
|
|
Try |
<--------------------
conn.Open()
Dim sqlInsertCommand2 As New SqlCommand(sqlstr, conn)
How can I do that please?
thanks,
|
by: =?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?= |
last post by:
I have a .NET VC++ program, I want to execute some dos command from the
program, e.g. copy some file, and etc. How do I do that?
|
by: abie16 |
last post by:
Hello All,
I have created a page with timer for the employee. They need to click start and stop button when doing their work. I want to have a pause button so when they going for break or anything they can just click the pause then once back they click the play button and the timer continue. Anyone can help me with the code. Thank you.
|
by: MZaza |
last post by:
What command can I use to make the program quite after a certain
condition?
--
Mustafa Zaza
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |