Error: assignment makes pointer from integer without a cast

Solved
Good evening,

An error message (assignment makes pointer from integer without a cast) appears when I run this code:

void proposeLetter(char letter, char* word, char* hiddenWord, int* attempts) { for (int i = 0; i < strlen(word); i++) { if (word[i] == letter) { hiddenWord[i] = letter; } else { attempts = i + 1; } } }


What is the problem?

Thanks in advance.

EDIT : Added code tags (syntax highlighting).
Explanations available here: HERE

Thank you for keeping this in mind in your future messages.

2 answers

  1. Moderator
    tries = i + 1; 


    tries is of type int*
    i is of type int
    that can't work, what do you want to do there?

    --
    I mainly work in VB6 and VB.NET, with a bit of C#, but moderation often brings me to other languages.
    In VB.NET make sure to enable "Option Explicit" and "Option Strict"
    1. Contributor
      he probably wants to increase the number of trials, and for that he needs to dereference the pointer by doing
      *trials
      to access the pointed content ... however, I don't see why he adds i + 1 (but that's another story).
  2. Thank you for your responses, the problem is resolved, it was just a slip of the mind ;-)

    --
    Don't forget to mark the subject as "resolved" when it is, and a little "thank you" is always appreciated ;-)