473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Clear Buffer before my Second Console.Read()

Okay I call Console.Read() twice. However when I come up on my second
Console.Read() ASCII character 10 is already on the console (that's a line
feed).

How do I clear out that line feed before I call Console.Read() again?
Nov 16 '05 #1
3 12372
Steve,

Can you show the code where this is happening? Console.Read shouldn't
be feeding you the line character (I think).

If anything, why not use ReadLine?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Okay I call Console.Read() twice. However when I come up on my second
Console.Read() ASCII character 10 is already on the console (that's a line
feed).

How do I clear out that line feed before I call Console.Read() again?

Nov 16 '05 #2
char letter = (char)Console.Read();

The first time through it is fine. The second time I can see in the
debbuger the a line feed is already in there.

I'm using Read instead of ReadLine becuase I just want a single char instead
of a string, and it seems like it would be simplier to do it this way.

Of course depending on what it takes to get around this issue I might change
my ind.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uu**************@TK2MSFTNGP15.phx.gbl...
Steve,

Can you show the code where this is happening? Console.Read shouldn't
be feeding you the line character (I think).

If anything, why not use ReadLine?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Okay I call Console.Read() twice. However when I come up on my second
Console.Read() ASCII character 10 is already on the console (that's a
line feed).

How do I clear out that line feed before I call Console.Read() again?


Nov 16 '05 #3
Steve,

You probably should do a readline. The reason for this is that when
dealing with console input, the buffer is not going to be filled until a
line is entered. Because of this, it's easier to just read the line and
process the string than it is to read character by character.

In .NET 2.0 however, there are ways of detecting when there is a
keypress, which might be of use to you.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:u$**************@TK2MSFTNGP14.phx.gbl...
char letter = (char)Console.Read();

The first time through it is fine. The second time I can see in the
debbuger the a line feed is already in there.

I'm using Read instead of ReadLine becuase I just want a single char
instead of a string, and it seems like it would be simplier to do it this
way.

Of course depending on what it takes to get around this issue I might
change my ind.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:uu**************@TK2MSFTNGP15.phx.gbl...
Steve,

Can you show the code where this is happening? Console.Read shouldn't
be feeding you the line character (I think).

If anything, why not use ReadLine?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Okay I call Console.Read() twice. However when I come up on my second
Console.Read() ASCII character 10 is already on the console (that's a
line feed).

How do I clear out that line feed before I call Console.Read() again?



Nov 16 '05 #4

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

Similar topics

19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
3
by: voidstar | last post by:
Hi, I have the following problem: I use "getch" to monitor keypresses and the I use "cin" to input a string. When I type in 'y', the 'y' character appears, so I need to hit backspace before...
5
by: nx-2000 | last post by:
I've got a very large C# forms app and now that its being used in bigger environments we're getting a steady stream of "why does it do this?" problems. The most nagging of which right now is that...
1
by: AD | last post by:
Hi I am trying to read elements of a vector from console (cin) in two steps ie, read a list of numbers from cin. Sort these. Then read from cin again and append in same vector. ...
1
by: noel.phillips | last post by:
Hi, I have two threads in my application, one that decodes audio to a stream and one that encodes a stream to a file. If I run them as two seperate processes I can pipe the output from one to...
2
Osoascam
by: Osoascam | last post by:
Hi! I made this code in order to "create" a buffer... It works perfectly when reading from console, but it just doesn't work for redinf from files. (Read after the function for the code...
331
by: Xah Lee | last post by:
http://xahlee.org/emacs/modernization.html ] The Modernization of Emacs ---------------------------------------- THE PROBLEM Emacs is a great editor. It is perhaps the most powerful and...
7
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...
9
by: pbd22 | last post by:
Hi. Does anybody know how to issue a clear screen command like DOS "cls" in a telnet session? Thanks!
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...

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.