Help designing a struct

We need to design a game for class and my group is storing all of the character's attributes in a struct. Below is the code that we have and visual studio gives us an error saying
error: class "std::basic_string<char,std::char_traits<char>, std::allocator<char>>" has no member "gold"
it gives us that error where i wrote name.gold = 0; is what i have correct for what i'm trying to do. the code below only creates the struct, declares the strings, starts the game, and gives the character a name that's user inputted.below that i have player name; which i believe declares that the player is the inputted variable name. is that the right way to do that? and below that it sets the value of gold to zero since you start with none. is that the correct way to do that? any help will be greatly appreciated. if you need any more information or clarification, let me know, i'll be happy to give any information you need.

#include <iostream>
#include <string>
using namespace std;
void clearScreen();
struct player{
int level;
int gold;
int health;
string magicPotion;
string strengthPotion;
string healthPotion;
string weapon;
string armor;
string spell;
};
int main ()
{

string name, map, start, destination, health, weapons, potions, ispeech1, ispeech2, pspeech1, pchoice1, pchoice2, wspeech;
string pchoice3, pchoice4, pchoice5, pchoice6, pchoice7, pchoice8, wchoice1, wchoice2, wchoice3,

cout << "Press 1 to start a new game, or press 2 to load your save. " << endl;
getline(cin, start);

clearScreen();

cout << "Welcome adventurer. What's your name? " << endl;
getline(cin, name);

player name;

name.gold = 0;
You have a player called name, and a string called name. You can't have multiple variables with the same identifier like that.
Topic archived. No new replies allowed.