| MirMohammad (12) | |
|
Hello! I have problem in my console app. For example I want to draw a calculator and then the user enter his numbers in a square in that cal. so I need to take the cursor there but have no idea how! So if anyone know how can I do this Plz Help! | |
|
|
|
| MirMohammad (12) | |
| Even so if it is possible with bat file commands tell me so I can make it by system() function ... help me ... I'm in short of time ... | |
|
|
|
| jumper007 (302) | |||||
Include the following code in your program.
When you call the function it should look like this:
EDIT: PS: The console has 20 lines and 80 columns. Hope I could help. ~ Raul ~ | |||||
|
Last edited on
|
|||||
| MirMohammad (12) | |
|
Thanks alot Raul! Yeah it worked. Would U plz explain it for me? What exactly does this gotoxy do? May I use it in Linux? | |
|
|
|
| jumper007 (302) | ||
|
Sorry for late reply. So, firstly, you have to include the <windows.h> header file in order to be able to use the specific console functions and variables: "
Now, what your own defined function is doing is actually having you get the control over the "console" via HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE) ;. Now that you gained control over it, you declare your cursor position as a COORD structure with two parameters X, and Y (where X represents the column and Y the line). SetConsoleCursorPosition( hStdout, position ) ; is the function that actually gives you the full control on the cursor position. It takes two arguments: the first is the variable which holds control on the console window and the second is the coordinate x,y pair.Actually, gotoxy(); is a function that exists in C, but it wasn't implemented in the official C++ libraries. Thus, using the already existing implemented functions you can create your own gotoxy(); function.For further details about this function I recommend reading on Microsoft Windows' website. As about using it in Linux, I am sorry but I am quite sure it won't work. I only program over Windows and I have been using this function. Maybe asking on the UNIX/Linux section of the forum and posting a link to this topic might get you to the answers you are looking for. Glad I could help. ~ Raul ~ | ||
|
Last edited on
|
||
| MirMohammad (12) | |
| Thanks alot Raul. I mean e.. really thanks. I O U | |
|
|
|
| jumper007 (302) | |
|
No problem mate. You can write me PM's whenever you need help. ~ Raul ~ | |
|
|
|