quand je fais le scanf je rentre une chaine de caractere et quand je veux l'afficher il m'affiche qsue le premier mot, il s'arrete au premier espace, pourquoi?
Le programme marche bien en lui meme il dois supprimer les espaces, mais il marche que lorsque je fais *txt="ma chaine"; mais si je fais scanf sa marche plus!! Merci de m'aider a+
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
37
38 #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> void decal (char *t); void main () { char txt[20]; scanf ("%s",txt); printf("\n%s",p); decal(txt); printf("\n %s",txt); getch (); } void decal (char *t) { int i,j; i=0; while(i < 20) { if(t[i]== 32) { j = i; while(j < 20) { t[j] = t[j+1]; j++; } i--; } else i++; } }
Partager