41

So you think you know C?

 4 years ago
source link: https://www.tuicool.com/articles/Ib2YRbb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

A lot of programmers claim they know C. Well, it has the most famous syntax, it has been there for 44 years, and it’s not cluttered with obscure features. It’s easy!

I mean, it’s easy to claim that you know C. You probably learned it in college or on the go, you probably had some experience with it, you probably think that you know it through and through because there’s not much to know. Well, there is. C is not that simple.

If you think it is — take this test. It only has 5 questions. Every question is basically the same: what the return value would be? And each question has a choice of four answers, of which one and only one is right.

1

struct S {
  int i;
  char c;
} s;

main() {
  return sizeof(*(&s));
}

2

main() {
  char a = 0;
  short int b = 0;
  return sizeof(b) == sizeof(a+b);
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK