Live data from Hacker News

Fixing C

embedded.com

121–123 of 123 posts

Re: Fixing C

#122
post #120

That's why it's a good practice to comment closing curly braces for the long blocks: while (1) { } // end of while

But before you do that, try pulling out functions.

Of course, but in embedded applications fairly large loops are common. It's not uncommon to see all code embedded inside a single while (1).

Re: Fixing C

#123
post #38

Earlier quoted context omitted.

Now, at one point, you stopped talking about arrays and started talking about pointers.

That's because C tosses out all of that array state information at the drop of a hat once you start passing them around to functions. Worse, it's an easy way to get burned on the sizeof() function, especially if you at some point refactor the code and put that chunk in a function separate from the original declaration. This is why C programmers get gunshy about relying on that information and instead just treat strin…

> This is why C programmers get gunshy about relying on that information and instead just treat strings like pointers all of the time.

Good programmers do nothing of the sort.

Post reply on HN