Hacker News new | past | comments | ask | show | jobs | submit login

YC != 42?



Obviously, YC == 5943


If you want an upvote, you'll have to show your work... ;)


man ascii ;)


Still haven't shown your work... did you remember to assign the numerical values of the string "YC" to the integer variable YC?

And did you remember to test against 0x5943, rather than 5943?

And did you take Endianness into account? ;-)


I guess I could do all that (truth be told, my C's a bit rusty for a prompt answer).

How 'bout:

  $echo -n "YC" > foo
  $hd foo
  00000000  59 43                                             |YC|
  00000002
Yeah, I know, perhaps 4359 might be better.

(UPDATE: fixed code spacing)


:-D


    printf("%hx", *(unsigned short *)"YC");
...works on big endian machines. this works everywhere:

    printf("%hx", htons(*(unsigned short *)"YC"));




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: