Add strings

This commit is contained in:
flyingscorpio@pinebookpro 2021-11-02 14:59:31 +01:00
parent 560ef65d1e
commit c8bd498410
2 changed files with 25 additions and 0 deletions

1
.gitignore vendored
View file

@ -27,3 +27,4 @@ min-max-moy
lettre-perdue
matrice-unitaire
addition-matricielle
strings

View 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;
}