and cout << it backwards but divided by each words... Example
Hi how are you? would become
iH woh era ?uoy
Here is where i am so far... It s in french... but i does not work... :(
It is the first time I use a Function... and not even sure if my backwards read is ok... I am trying hard, but would really need help. I am so far as that when I compile... it cannot open the program...
//Déclariation des prototypes des fonctions locales
char Mot(char *pInverse);
//---------------------------------------------------------------------------
//Fonction principale du programme
//Descritption: Lit une ligne de 80 caracteres maximum et affiche la ligne en
// inversant les lettres de chaque mot.
//---------------------------------------------------------------------------
void main()
{
//
//Définition des variables locales
//
char Phrase; //La ligne de 80 caracteres maximum
//
//Instructions
//
cout<<"SVP entrer une ligne de texte contenant un maximum de 80 caracteres et qui se termine par un pochar: \n";
cout<<"--------------------------------------------------------------------------------------------------\n\n";
//
// Saisie de la phrase
//
cin >> Phrase;
//
//Vérifier si la lecture de l'information s'est bien passée
//
if(cin.fail())
{
cout<<"\n\n Erreur --- Votre phrase contient plus de 80 caracteres. \n\n";
}else
{
while(Phrase =' ') //Valide si un espace () ou un pochar (.) est fait
{
if(Phrase = '.')
{
}
}cout << Mot(&Phrase) << "\n";
}
//
//Resultat demande
//
//cout <<
//
//Fin du programme
//
cout <<flush;
_getch();
}
//---------------------------------------------------------------------------
//Fonction: Inverse
//Descritption: Inverser chaque mot par adresse
//---------------------------------------------------------------------------
char Mot(char* pEndroit,char* pInverse, int pos)
{
char lreturn;
int index = 0;
int len = strlen(input);
for(int i = pos; i < len; i++)
{
output[index] = input[i];
index++;
}
output[index] = 0;
Your function prototype is different from the implementation of your function. At the top you have char Mot(char *pInverse); but at the bottom you declare it as char Mot(char* pEndroit,char* pInverse, int pos). These need to have the same number and type of arguments.
#include <iostream>
#include <sstream>
#include <algorithm>
usingnamespace std;
int main( int argc, char* args[] ) {
// read in a sentence
string sentence;
cout << "Enter a sentence: " << endl;
getline( cin, sentence );
// seperate the sentence into "words" delimited by whitespace
string word;
istringstream sin( sentence );
while( sin >> word )
{
// reverse the characters
reverse( word.begin(), word.end() );
// output the word followed by a space
cout << word << " ";
}
// output a newline
cout << endl;
return 0;
}