C#:
using System;
namespace DELETEONEDAY
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
char[] userInput = new char[4];
Console.WriteLine("Please input 4 numbers. (after each number press the enter key).");
for(int x = 0; x <=3; x++)
{
userInput[x] = (char)Console.Read();
}
for(int x = 0; x <=3; x++)
{
Console.WriteLine(userInput[x]);
}
}
}
}
this code looks simple enough... you may wonder why i posted it.
I run this code expecting to input 4 chars then displaying them on the screen...
It loops 4 times as expected but only prompts me for input twice??????
heres an example of what happens when i run it.
<user input: 1>
<user input:2>
program displays
1
2
the 2nd and 3rd Console.Read statements are run by the program but it does not pause for me to input the value.
im stumped.
(if you are wondering why i have made such a simple program its because this is actually a java program i must write for school. the results seemed so bizzare to me, i swithced over to C# and ran the same code again only to have the same results. we arent required to use the loops but only because we havent learned them yet... i thought i was good to go but.. maybe im wrong)
******edit***** problem sovled
ok so it works if i hit enter after i enter all 4 char... thats cool cuz it works...
but why is the user prompted twice if enter is pressed after each input char?
(im happy its fixed but confused as to what happens when the user screws up)
brandon
Last edited by a moderator: