I need to enter a sentence and the program has to write the words backwards
using a function. Mean if i enter i'm bored i should get bored i'm
I've only managed to do this
Code:#include<stdio.h> #include<string.h> void Func21Mas(char *s, int n) { char *sen=s; for (int i=n-1; i>=0; i--){ while (*sen) printf("%c",*sen++); sen++; printf(" "); } } void main() { int k=0; char sent[100], *ptrtok, *words[20]; gets(sent); ptrtok=strtok(sent," "); while(ptrtok){ words[k]=ptrtok; k++; ptrtok=strtok(NULL," "); } Func21Mas(*words,k); /*for (int i=k-1; i>=0; i--){ while (*words[i]) printf("%c",*words[i]++); printf(" "); }*/ }



LinkBack URL
About LinkBacks


