Langage C

  • Uploaded by: Gogol Plex
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Langage C as PDF for free.

More details

  • Words: 149
  • Pages: 2
© Mr HousNi * [email protected]

Exemple de Manipulation des Chaines de Caractères #include <stdio.h> #include <stdlib.h> #include<string.h> int main(void) { char mot1[100], mot2[100]; int l, n; printf(" Donner mot1:\n"); gets(mot1); printf(" Donner mot2:\n"); gets(mot2); // concaténation strcat(mot1,mot2); printf(" Concatenation de mot1 et mot2:\n"); puts(mot1); // longeur de la concaténation l=strlen(mot1); printf(" Longueur de la concatenation:\n%d",l); // inverser la concatenation strrev(mot1); printf("\n Concatenation inverse:\n"); puts(mot1); // comparaison alphabétique printf(" Comparaison alphabetique de %s et %s\n",mot1,mot2); if(strcmp(mot1,mot2)>0) {puts(mot2); puts(mot1);} if(strcmp(mot1,mot2)==0) printf("identique"); if(strcmp(mot1,mot2)<0) {puts(mot1); puts(mot2);} // copie de mot2 dans mot1 strcpy(mot1,mot2); printf(" Copie de mot2 dans mot1:\n"); puts(mot1); // existence de a dans mot1, idem strrchr en commençant par la fin printf(" Existence de 'a':"); if(strchr(mot1,'a')!=NULL) printf("\n'a' existe!"); else printf("\n'a' n'existe pas!"); // existence de ab dans mot1 printf("\n Existence de 'ab':"); if(strstr(mot1,"ab")!=NULL) printf("\n'ab' existe!"); else printf("\n'ab' n'existe pas!");

}

printf("\n"); system("PAUSE");

1/2

© Mr HousNi * [email protected]

Capture d'écran

2/2

Related Documents

Langage C
May 2020 17
Langage C
June 2020 16
Langage C
June 2020 12
Langage C
June 2020 16
Langage C
June 2020 15
Langage C
June 2020 13

More Documents from "Gogol Plex"

June 2020 11
Langage C
June 2020 15
Langage C
June 2020 13
Analyse
June 2020 23
June 2020 12
Langage C
June 2020 16