hi,
I want to know how to modify this code so that i can do there?
1. if there is any sort of punctuation, put that at the end of the converted word.
2. if there is no vowel, add "way" to the end.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
static int isVowel ( char ch )
{
ch = toupper ( ch );
return ( ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U' ) ? 1 : 0;
}
static char *transWord ( char *word )
{
int i, j;
char temp[80]; memset ( temp, '\0', 80 );
if ( isVowel ( word[0] ) ) {
strcat ( word, "way" );
return word;
}
else {
for ( i = 0; !isVowel ( word[i] ); i++ );
for ( j = 0; word[i] != '\0'; i++ )
temp[j++] = ( ispunct(word[i]) ) ? '`' : word[i];
for ( i = 0; !isVowel ( word[i] ); i++ )
temp[j++] = tolower ( word[i] );
strcat ( temp, "ay" ); strcpy ( word, temp );
}
return word;
}
int main ( void )
{
char buffer[1024], final[1024], word[80], *temp;
memset ( final, '\0', sizeof final );
puts ( "Enter a phrase or sentence" );
scanf ( "%1024[^\n]", buffer );
temp = strtok ( buffer, " \0" );
while ( temp != NULL ) {
strcpy ( word, temp );
temp = transWord ( word );
strcat ( final, temp ); strcat ( final, " " );
temp = strtok ( NULL, " \0" );
}
final[0] = toupper ( final[0] ); puts ( final );
return EXIT_SUCCESS;
}