Problem with a variable

I have declared a variable in my .h file like this:

char c;

This should, in my mind, declare a variable called c as a character. I have then used it like this in my .cpp file:

c = tolower(getchar());

if (c = “w”){move forward}

else if (c = “a”){move left}

else if (c = “s”){move down}

else if (c = “d”){move right}

I have actual code instead of all the moves.
For some reason, it doesn’t like all the "c = " bits inside the if statements. Why is this and how would I fix it? I have used all the following includes, I don’t think I’m missing any:

.h file:

#include “CoreMinimal.h”’

#include “GameFramework/Pawn.h”’

#include “Duck.generated.h”’

.cpp file:

#include “Duck.h”’

#include “HotACold.h”’

#include “Camera/CameraComponent.h”’

#include “c:/Program Files/Epic Games/UE_4.16/Engine/Source/Runtime/Engine/Classes/GameFramework/SpringArmComponent.h”’

#include “stdio.h”’

#include “ctype.h”’

#include “conio.h”’

c = “w”

is an assignment
You want to ask if it is equal with

c == "w"

But that would be not really correct too.
If you work with one char, you should use ’ not "
So it should be:

c == 'w'

There might be other problems after this, just compile after the changes and ask again if needed.

That made it work, thank you! Glad I got that solved, now I just need to figure out what’s going on with the compiler. It seems to freak out and give me loads of errors that just aren’t errors.

The newest problem is that it’s giving me about 50 errors when I compile, none of which actually exist, which means I can’t check if the code works properly or not. I’ll post another question about it soon.

Good.
Could you mark the answer as “answer” then?

And like I said, just ask away.
Some times people just know the answers.

But some times you have to wait because of the time difference :slight_smile: