Re: How to understand this line of c ?
- From: Roberto Waltman <usenet@xxxxxxxxxxxx>
- Date: Sat, 31 Dec 2005 14:41:36 -0500
"lnzju" <geniuslee@xxxxxxxxx> wrote:
>main(_){for(--_;putchar(_++["J!Mpwf!Zpv\1"]-1););}
The two following code fragments are equivalent:
/*-A-----------------------------------*/
#include <stdio.h>
int main(void)
{
char rubbish[] = "J!Mpwf!Zpv\1"; /* will 'print' trailing '\0' */
char *rp = rubbish;
while (*rp)
{
putchar ((*rp)-1);
rp++;
}
putchar('\n'); /* not in original code */
}
/*-B-----------------------------------*/
#include <stdio.h>
int main(void)
{
char rubbish[] = "I Love You\0"; /* '\0' is redundant here */
char *rp = rubbish;
while (*rp)
{
putchar(*rp);
rp++;
}
putchar('\n'); /* not in original code */
}
/*-------------------------------------*/
.
- References:
- How to understand this line of c ?
- From: lnzju
- How to understand this line of c ?
- Prev by Date: Re: How to understand this line of c ?
- Next by Date: Re: Adding the ability to add functions into structures?
- Previous by thread: Re: How to understand this line of c ?
- Next by thread: Happy New Year
- Index(es):
Relevant Pages
|