Docs Wiki
Advertisement
/* Tomi Babalola and Kevin Duke */
/* Lab 08 */
/* 11-21-09 */

#include <stdio.h>
#include <string.h>
#define STRING_SIZE 90

void wordReverse(char words[],char words2[]);

int
main(void)
{
 char string[STRING_SIZE];
 char revstring[STRING_SIZE];
 int length;

 printf("Please enter a word no longer than 19 character\nthat you would like to see reversed: \n");
 scanf("%s", string);

 printf("the word entered is:%s\n", string);
 length=strlen(string);
 wordReverse(string, revstring);

 printf("The word reversed is:%s\n", revstring);

return 0;
}

void wordReverse(char words[], char words2[])
/* words is the string inputed by the user
 words2 is the reversed version of the inputed string
*/
{
 int slen; /* string length */
 int i;

slen = strlen(words);
for (i = 0; i <= slen ; i++)
 words2[i] = words[slen - 1 - i];
return;
}
Advertisement