English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Example: I will ask the user to enter a word. Say, he entered, 'Beautiful' The outcome will be: 'lufituaeB'

2006-08-07 00:35:45 · 3 answers · asked by sublime 3 in Computers & Internet Programming & Design

***NOTE: strrev is not allowed.

2006-08-07 00:52:50 · update #1

We are supposed to use arrays. Just that, I think.

2006-08-07 01:00:50 · update #2

***Instructions: Write a program that accepts (3) strings from the user. Create a function that reverses the string. Do not use the strrev function found in string.h

2006-08-07 01:04:29 · update #3

***Instructions: Write a program that accepts (3) strings from the user. Create a function that reverses the string. Do not use the strrev function found in string.h

2006-08-07 01:04:33 · update #4

3 answers

try this one:

#include
#include

rev(char * s),j,i;
char inbuf[20],conv[20],n;

int main()
{
printf("enter a word with max 20 characters : ");
fgets(inbuf, 20, stdin);
rev(inbuf);
printf("the reverse word is %s",inbuf);
}

rev(char * s)
{
j=0;
for (i=21;i>0;i--)
{
conv[j]=inbuf[i];
j++;
}
return conv;
}

2006-08-07 00:56:48 · answer #1 · answered by Anonymous · 1 1

#include and then use the function strrev(stringName);
to reverse. Or if you need the logic then above provided solution will work fine..

2006-08-07 00:48:21 · answer #2 · answered by ccsCoder 3 · 0 0

void reverse(char *str)
{
int i=strlen(str);
int j=0;
char x;
for(j=0;j {
x=str[j];
str[j]=str[i-j-1];
str[i-j-1]=x;
}
}

2006-08-07 00:45:03 · answer #3 · answered by Nikhil G 3 · 0 0

fedest.com, questions and answers