Add strings
This commit is contained in:
parent
560ef65d1e
commit
c8bd498410
2 changed files with 25 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -27,3 +27,4 @@ min-max-moy
|
|||
lettre-perdue
|
||||
matrice-unitaire
|
||||
addition-matricielle
|
||||
strings
|
||||
|
|
24
programmation-c-cpp/tp3/strings.c
Normal file
24
programmation-c-cpp/tp3/strings.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* Les strings */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int main() {
|
||||
char chaine[] = {'S', 'a', 'l', 'u', 't', ' ', 'l', 'e', 's', ' ', 'c', 'o', 'd', 'e', 'u', 'r', 's', '!', '\0'};
|
||||
|
||||
// Affichage de la chaîne complète
|
||||
printf("%s\n", chaine);
|
||||
|
||||
// Affichage du premier mot
|
||||
int i = 0;
|
||||
while (chaine[i] != ' ') {
|
||||
i++;
|
||||
}
|
||||
chaine[i] = '\0';
|
||||
printf("%s\n", chaine);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue