#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include <conio.h>
void gotoxy(int x, int y)
{
COORD pos = { x,y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void ma_in(void) {
printf("▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩\n\t\t\tTHE Parkour\n▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩\n\n\nPress the s key to get started!");
char a;
a = getch();
while (1) {
if (a == 115) {
system("cls");
break;
}
}
}
void move(void){
int a, x = 0, y = 0;
while (1) {
a = getch();
if (a == 114) {
y--;
}
else if (a == 115) {
y++;
}
else if (a == 97) {
x--;
}
else {
x = x;
}
gotoxy(x, y);
printf("a");
Sleep(50);
system("cls");
}
}
int main() {
int xy[30][30];
RE:
ma_in();
system("cls");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3);
printf ("move: wsad, enable: F");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0);
move();
}
When you post a question, if possible, if you post in detail what the results are, what problems have occurred, and what causes you expect, you are more likely to hear the answer you want.
Basically, the code you uploaded won't be able to compile itself, so I'll think of it as an answer that you want to compile well!
You entered the code a = getch();
in the codes 20 line and 32 line .
If you compile the latest version of the visual studio from this state, you will get the following error statement.
Error C4996 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conform name: _getch.
The word defined
is important here.
deferred
means a function that was used in the past but is no longer used.
After the function was implemented, it was discovered that there was something wrong with it (mostly it was a security flaw), and the person who created it created a new function that complemented it
To prevent programs that are writing this function from working differently than intended
A complemented function is to create a function with a new name and warn you not to use it anymore if you use an old function.
The best way to resolve this is as the error message states
a = getch()
Replace this part with a function that has been changed like a = _getch()
.
There's also a way to solve this problem
At the top of the source code
If you enter the code #pragma warning (disable:4996)
To the compiler, I'm going to force an old function. That's what I'm telling you, and eventually it's compiled
This method is not recommended unless there is a specific reason.
To give you a popular example of this problem while studying C language, it's a scanf
function.
Books written in the past are written to use the scanf
function when receiving input.
The latest version of the Visual Studio compiler recommends using the scanf_s
function.
© 2024 OneMinuteCode. All rights reserved.