I don't know C++, but here's an R solution.
secret = "penis"
count = 0
max_guesses = 7
while(TRUE){
guess = as.character(readline('Guess letter: '))
print(guess)
if(grepl(guess, secret) && nchar(guess) == 1){
print(paste0(guess, " was in the word!"))
secret = gsub(guess, '', secret)
}else{
print("Not in word")
count = count + 1
}
if(nchar(secret) == 0){
print("ayy")
break
}
if(count >= max_guesses){
print("lmao")
break
}
}