I'm getting the following output:

 :| inline comments are discouraged 

when I use style50 in terminal window.

I thought that commenting while coding was something like "must have." How is style graded? Does getting that output mean I would get less than full points for my code style?

I use comments on the same line as code and comments on their own lines, but mostly I prefer the first one.

  • I just mean that you can really comment your code any way that you like. But for cs50 work, they expect you to adhere to the format of the second one in my answer. That is, // comment on its own line, code on the next line. In the first example in my answer the format is code; immediately followed by a comment on the same line. Sep 3 '14 at 18:23
  • 1
    Also, if it helps you understand 'why does cs50 care how I comment my code', they'll tell you that learning to ahere to certain "style guidelines" is good, since if you ever go and get a job at a tech company, they will likely enforce their own style guidelines, so you'll get yourself into trouble if your not able to adapt to the specifications of whatever work you're doing. Sep 3 '14 at 18:27
  • thanks for the comments @anthonygiuliano :-) Now I understand it, thanks to you ;-) Sep 4 '14 at 8:42

Are you comments like this:

    printf("hello, world\n"); // print greeting

Or like this:

    // print greeting
    printf("hello, world\n);

Nothing really wrong with either, although I think that the latter is the preferred format and I'd argue that it's easier to see what's going on.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .