hello, im just a beginner and im having problems in printing out string in reverse, can you give me an example as to how i can print helloworld in the format dlrowolleh?? it will be much appreciated!! thankyou!!
Printable View
hello, im just a beginner and im having problems in printing out string in reverse, can you give me an example as to how i can print helloworld in the format dlrowolleh?? it will be much appreciated!! thankyou!!
> im having problems in printing out string in reverse
Such as?
What have you tried to do so far?
Can you - for example - print a string out one character at a time forwards?
yes i can print out the string hello world forwards, but i cant figure out the for function to print it in reverse,
how about
for ( i = strlen(msg ) ; i >= 0 ; i-- )
Or try this !
void main()
{
char *alphabet = {" the alphabet"};
char *coded + {"the alphabet in reverse"};
char message[50];
char *m_ptr = message,
*a_ptr = alphabet,
*c_ptr = code;
printf("\nEnter message");
gets(message);
while( *m_ptr)
{
while( *m_ptr != *a_ptr++ )
c_ptr++;
*m_ptr = *c_ptr;
a_ptr = alphabet;
c_ptr = code;
}
printf("\nthe message was > %s", message);
}
another compy lesson:D
Me too, me too! I want to do their homework!!
[code]
#include <stdio.h>
#include <string.h>
int main(void){char b[1024]={0},c;int x,y;fputs("Enter a string:",stdout);fgets(b,1024,stdin);for(x=0,y=str len(b)-1;
x<strlen(b)>>1;x++){c=b[x];b[x]=b[y-x];b[y-x]=c;}fputs(b,stdout);return!1;}
[\code]
Teachers appreciate compact code.
Quzah.
K!!!
is this anomosity?
say what you mean why don't you.
:o