salut à tous,
je viens chercher des conseils pour régler un problème ( surement très simple à corriger ) qui fait planter mon revstr ..
en effet celui ci m'affiche la phrase suivante lorsque je compile : my_revstr.c:40:12: warning: initialization makes integer from pointer without a cast [enabled by default]
char i = "moo";
cette phrase s'affiche également pour "char j = "foobar";
je connais la sygnification de cette erreur mais dans le cas présent je ne vois absolument pas comment régler le problème .
Ducoup quand j'execute le programme le caractère suivant s'affiche "" , a quoi correspond ce caractère ??
j'espère que pour mon premier post, celui ci est compréhensible et je vous remercie d'avance pour l'aide.
bonne soirée !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 int my_strlen(char *str) { int b; b = 0; while (str[b] != '\0') b++; return (b); } char *my_revstr(char *str) { char x; char i; char j; i = 0; j = my_strlen(str) - 1; while (i < j) { x = str[i]; str[i] = str[j]; str[j] = x; i++; j--; } return (str); } int main() { char *str; char i = "moo"; char j = "foobar"; printf("%s", my_revstr(str)); }
Partager