Error: assignment makes pointer from integer without a cast

Solved
Unnamed_Man Posted messages 47 Status Member -  
Unnamed_Man Posted messages 47 Status Member -
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. NHenry Posted messages 15235 Registration date   Status Moderator Last intervention   387
     
    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"
    0
    1. [Dal] Posted messages 6122 Registration date   Status Contributor Last intervention   1 108
       
      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).
      0
  2. Unnamed_Man Posted messages 47 Status Member 5
     
    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 ;-)
    0