I'm trying to make a program takes the input to a name such as :
Doe, John...and then have it have John Doe at the output. Any help would be appreciated. I'm using turbo C as a compiler and here is what I have thus far......thanks
#include <stdio.h>
#include <string.h>
void pause(void);
int main()
{
char word[30][21];
char reverse[30][21];
int length
int w1count;
char run;
char c;
clrscr();
printf("The following program will reverse a name ");
printf("the user enters.\n\n");
printf("Do you want to run this program? Y for yes, N for no.\n\n");
scanf("%c", &run);
if(run == 'n' || run == 'N')
{
return 0;
}
else
clrscr();
printf("Please enter a name. Ex. Doe, John.\n");
for (count = 0 ; ; )
{
scanf("%s", word[count]);
length = strlen(word[count]) - 1;
c = word[count][length];
if ((c != ','))
count++;
else
break;
}
clrscr();
printf("The original name entered was: \n\n");
for (count = 0 ; ; )
{
printf("%s ", word[count]);
length = strlen(word[count]) - 1;
c = word[count][length];
if ( (c != ',')) )
count++;
else
break;
}
printf("\n\nThe modified name is: \n\n");
count = 0;
again:
length = strlen(word[count]) - 1;
c = word[count][length];
if ( (c !=',')) )
{
reverse[count][length] = word[count][length];
for (w1count = 1 ; w1count <= length ; w1count++)
{
reverse[count][w1count - 1] = word[count][length - w1count];
printf("%c", reverse[count][w1count - 1]);
}
printf("%c ", reverse[count][length]);
}
else
{
((reverse[0][0] >= 'a') && (reverse[0][0] <= 'z'))
reverse[0][0] = reverse[0][0] - 32;
printf("%c", reverse[count][w1count]);
}
}
c = word[count][length];
if (( c != '.') && (c != '?') && (c != '!'))
{
count++;
printf(" ");
goto again;
}
count++;
printf("\n\nPress any key to continue...");
for (;
if ( kbhit() )
break;
getch();
}