473,915 Members | 3,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with console problems

Hello!!

I'm doing a program with C++. First I couldn't see the results because
the console close. After a little research I found that I can use a
cin.get() or a getch() and that works fine. I mean my program print a
line and is waitting for an input, but after I write something and
press enter the console closes eventought it has getch() or a
cin.get() on the next instruccion.

I know this is a dumb question but I can't find a solution. Any help
would be appreciate!!

Thanks!!!

Feb 8 '06 #1
2 1337
Hugo wrote:
I'm doing a program with C++. First I couldn't see the results because
the console close. After a little research I found that I can use a
cin.get() or a getch() and that works fine. I mean my program print a
line and is waitting for an input, but after I write something and
press enter the console closes eventought it has getch() or a
cin.get() on the next instruccion.

I know this is a dumb question but I can't find a solution. Any help
would be appreciate!!


IIRC, this is covered in the FAQ. Something about 'ignore' before the
'get'... What happens is that your "Enter" character is still in the
buffer when you try to tell it to wait...

V
--
Please remove capital As from my address when replying by mail
Feb 8 '06 #2
I'll review the FAQ!! Thanks a lot Victor! I have had this problem for
many days!!!

Feb 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2770
by: 0k | last post by:
Hi everyone, I am trying to write a small app that sends multicast udp packets using a socket object. I have more than one NIC on my PC and the following code works OK only if I disable all the NICs but the one i want to use. Of course i tried to use Socket.Bind method, but even if i use it to bind to the correct NIC (I also verify using LocalEndPoint and IT IS the correct one), the packet is sent on the wrong NIC! (I have a software...
16
2826
by: Simon | last post by:
I am a programming student and have recently missed two weeks of school due to a serious injury in a car accident. I am completing all of my assignments (via Labs) but have come across the following lab and can't seem to put it all together. The scenario: A small airline has just purchased a computer for its new automated reservations system. You have been asked to program the new system. You are to write a program to assign seats...
7
1814
by: MuZZy | last post by:
HI I just wonder if someone can help me with this: I have a windows app project developed on VC++ 6.0. I need to adapt it to be able to compile as a console app as well (So it would call main() instead of WinMain()) I created a new profile for the project and replaced precompile define _WINDOWS by _CONSOLE, and changed linker option /subsystem:windows to /subsystem:console.
5
2178
by: Chua Wen Ching | last post by:
Hi, I read from this tutorial at codeproject Question A: http://www.codeproject.com/csharp/GsXPathTutorial.asp regarding xpath.. but i try to apply in my situation, and can't get it work...
5
1547
by: Matthew Speed | last post by:
(About me: I know very little about writing server applications. I have done plenty of VB6 desktop app work but this is my first server program. I got it to work by modifying examples. I understand what it is doing but not much about what is involved in extending it. ) I am not necessarily looking for code examples here, just some pointers as to what direction I need to proceed to resolve these things. I have written a...
1
8493
by: Cory Koski | last post by:
Hi all, I'm currently trying to build a component I can use in traditional ASP that utilizes the .NET webservice. I'm using VB.NET to create my class, and I am registering the class for COM Interop when I compile. I'm encountering some problems with testing using the class in a VB.NET console application. I keep getting a http 405 error (I've never seen this kind of error before). In Visual Studio, I get this error:
11
3765
by: Nurit N | last post by:
This is the third newsgroup that I'm posting my problem. I'm sorry for the multiple posts but the matter becoming urgent. I hope this is the right place for it... I have created a very simple batch file (echo hello world) and was trying to retrieve the standard output but every time I run the code it returns ExitCode as 1.
3
1732
by: Andrew Ducker | last post by:
We were using Console.Writeline from within our app, to do some routine debugging. And then we started having random problems when the code was run by a tester, on their own machine. We couldn't replicate these problems on the developer machines. And then we eventually worked out that on the dev machines Console output was going to a window, and on the test machines it was going....nowhere.
22
7714
by: j1mb0jay | last post by:
I have had to create a simple string encryption program for coursework, I have completed the task and now have to do a write up on how it could be improved at a later date. If you could look through the code and point me in the correct direction one would be very grateful. Example Input : j1mb0jay Example Output 1 : rZHKZbYZWn/4UgL9mAjN2DUz7X/UpcpRxXM9SO1QkvkOe5nOPEKnZldpsB7uHUNZ Example Output 2 :...
7
10457
by: Just Me | last post by:
I am writing a small windows applicationa and I am writing console.writeline data to the console window. But i wanted to clear the area before writing to the window. I found the console.clear method, but when I run it it fails with an uinhandled exception and the exception is that it does not have the handle to the window. IM assuming, I need to determine the console windo handle, but Im not sure, has anyone used this, can point me in...
0
10039
marktang
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...
0
11359
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9734
agi2029
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...
0
7259
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();...
0
5944
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...
0
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4346
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3370
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.