If I'm not mistaken, getch() isn't defined by either C or C++ standard. Using a test case and replacing getch() with std::cin.get(), I get http://ideone.com/clone/Agb0h
I can't do anything else for ya without more info.
If I'm not mistaken, getch() isn't defined by either C or C++ standard
So what. If it isn't defined by the standard it doesn't mean that you cannot use it( if this is what you mean ). I use getch( ) all the time. All you need is the conio.h header to access it.
So, you'd rather lose cross-platform capabilities just to use getch() instead of getchar() or std::cin.get()? Might I add that most online sample compilers provided by sites such as codepad.org or ideone.com don't allow getch().
Aside from that, I'm not saying that's his problem. We can't determine his problem without more information.
Framework, we've deprecated the conio.h header simply because it's old and tends to vary in functionality between implementations. I'd like to suggest that you use something newer and less random for your projects. :|
Well... it's your programing style, I guess. conio.h is still being (somewhat) maintained by Microsoft, so I suppose it's not a case of severe deprecation.
Still, using a header whose functions vary somewhat from compiler to compiler doesn't strike me as a good idea. :/
What I'm doing is inputing a value for a space in my array (buy[0]), and then testing to see whether or not it's stored. The b = getch() thing is just my way of testing if it's still stored. When I press 1 after it's stored, it should print buy[0], or the value I inputed. Yes? No? D:
There is no value stored in b. The value is stored in buy[0], and then I just need some variable for my keyboard input, as in when b = keyboard input of 1, then print buy[0] (which is what i inputed before.
Here, let me write out what I'm trying to do in words to make it easier for you all to understand:
All I am trying to do is better understand Arrays and make sure I know what I'm doing before I move on. So, first, the program takes an input value, and stores that value in space 0 of buy[]. (cin >> buy[0]) The value stored is an interger (2 for example). Next, it prints a line of text. Then it waits for another input from the keyboard (b = getch() this is the test part). I'm using b just as a random variable for this input value. If this input turns out to be 1, then it will print buy[0], or 2 in this case. Why is this not working?
Also, side note. I tried changing if (b=='1') to if (b=='49') and it worked.