Odd output on console, assuming its got to do with pointers

I was trying to retrieve an enemy's name once the player was able to defeat them, something I added into a game tutorial I was on, but the output it created was an infinite symbol, equal sign, and a circle. Anyways, here's the code, I'm just involving what i'm assuming is relevant, but if anymore is needed let me know.
//where enemy name is being outputted to console
if (targetX == enemyX && targetY == enemyY)
{
attackRoll = player.attack();
printf("You attacked %s for %d damage!\n", _enemies[i].getName(), attackRoll);
attackResult = _enemies[i].takeDamage(attackRoll);
if (attackResult != 0)
{
setTile(targetX, targetY, '.');
print();
printf("%s was killed by player!\n", _enemies[i].getName());
player.addExperience(attackResult);
return;
}
//where enemy name is in enemy.cpp
string Enemy::getName()
{
return _name;
}
//where name is originally created
Enemy::Enemy(string name, char tile, int level, int attack, int defense, int hp, int experience)
{
_name = name;
_tile = tile;
_level = level;
_attack = attack;
_defense = defense = defense;
_hp = hp;
_experienceValue = experience;
}
I figured out the problem, I forgot to use c_str() at the end of strings in the printf functions.
Topic archived. No new replies allowed.