Don't know if this is the most efficient way to do it but here's a WORKING EXAMPLE:
Once word is passed to the function swapfront, word now holds the new arrangement of characters.Code:#include <cstdio> #include <cstring> void swapfront(char[]); int main() { printf("Enter word:"); char word[256]={0}; scanf("%s",&word); swapfront(word); printf("%s\n",word); return 0; } void swapfront(char word[]) { char f; f=word[0]; char temp[256]={0}; int i=1; for(int b=0;b<strlen(word);b++) { temp[b]=word[i]; i++; } temp[strlen(word)-1]=f; strcpy(word,temp); }



LinkBack URL
About LinkBacks



