Error: assignment makes pointer from integer without a cast
Solved
Unnamed_Man
Posted messages
47
Status
Membre
-
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:
What is the problem?
Thanks in advance.
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
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"
[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 to access the pointed content ... however, I don't see why he adds i + 1 (but that's another story).