Quel est le programme pour imprimer la chaîne inversée d'une chaîne donnée ?

1 Réponses


  • Incluez le fichier d'en-tête string.h dans votre programme. Et utilisez la fonction strrev() pour inverser la chaîne donnée.  Exemple C++ : #include<iostream.h> #include<string.h> #include<conio.h> void main(){ char st[100]; cout<<"Entrez la chaîne :" ; cin>>st; cout<<"Chaîne inversée :"<<strrev(st); getch(); } Exemple en C : #include<stdio.h> #include<string.h> #include<conio.h> void main(){ char st[100]; printf("Entrez la chaîne :"); scanf("%s",st); printf("Chaîne inversée : %s",strrev(st)); getch(); }

Ecrivez votre réponse

Votre réponse apparaîtra après modération