Error: assignment makes pointer from integer without a cast

Solved
Unnamed_Man Posted messages 47 Status Membre -  
Unnamed_Man Posted messages 47 Status Membre -
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 réponses

NHenry Posted messages 2510 Registration date   Status Modérateur Last intervention   386
 
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
[Dal] Posted messages 6205 Registration date   Status Contributeur 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
Unnamed_Man Posted messages 47 Status Membre 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