I am new to programming and I can only use C++. I have been working on an RPG, and for some reason I can't get the program to print out the value that I set a string to. I started by defining the string "weapon" in void main.
void main()
{
string weapon;
cin >> weapon;
if(weapon = "A")
{
weapon == "sword";
}
}
I had the code sort of like this and I had a function above it that uses "weapon" (which was set to sword as you can see from the code above) at the end of something that I had it print out, but that was in the function (which was above the void main) so in order to get both to be defined variables I had to define them in both the void main and the function, but when I do that, nothing appears in the program when it's run. I had everything written correctly (what I put above is just an example) but the only way that it doesn't create an error is by defining it in both parts of the code. It says that one of them hasn't been defined yet so I defined it both the function and the void main. Why isn't it working? How do I fix it? Thanks
P.S. I did include the string library and namespace.