How to resolve Signal: Segmentation fault (core dumped) in C++

Asked

Viewed 36 times

0

I’m trying to make a noose and on that part, always gives the core error dumped. how can I solve this problem?

cout << newnome1 << ", ESCOLHA UMA PALAVRA:   ";
cin >> palavraSecreta;

while(tela[j] != '\0') {
  j++;
  tam++;
}


for(j=0; j<tam; j++) {
  tela[j] = '_';
 }

while(max <= 5) {
  for(j=0;j<tam;j++) {
     cout << tela[j];
  }
cout << "\n\nDigite uma letra:  ";
cin >> letra;
for(j=0;j<tam;j++){
 if (letra == palavraSecreta[j])
   tela[j] = letra;
 else
   cout << "letra errada, tente novamente" << endl;
   max++;
}
}

I cannot replace string letters to "" and then print the "" or replace the "_" with letters. I’ve seen several tutorials and keeps giving same error.

I appreciate any help.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.