#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <Windows.h>
#include <string>
int main(){
std::string grid = "0000000000\n""0000000000\n""0000000000\n""0000000000\n""0000000000\n""0000000000\n""0000000000";
char user;
user = 'G';
int n = 0;
std::cout << grid;
while (n != grid.length()){
if (GetAsyncKeyState(VK_LEFT)){
grid.at(n) = 0;
n++;
grid.at(n) = user;
std::cout << grid;
}
}
}
The problem is that the while loop keeps on looping like I keep on clicking the left key , also, there is always a space between the last 0 before the G and the G. Please help.
I don't know Windows programming, so I don't know why you keep getting left-clicks, but I suspect it's because you're checking if the button is down but never make sure it went back up.
However, I do know that you need to be careful about replacing the 0's and G's because you're overwriting your '\n's