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!!
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?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
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-- )
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
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
Before you judge a man, walk a mile in his
shoes. After that, who cares.. He's a mile away and you've got
his shoes.
************William Connoly
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.
Hope is the first step on the road to disappointment.
K!!!
is this anomosity?
say what you mean why don't you.
Before you judge a man, walk a mile in his
shoes. After that, who cares.. He's a mile away and you've got
his shoes.
************William Connoly