0

Having completed the first 4 psets and having little prior programming experience I start to worry about my style(comments, identation etc.)

I would like to hear some comments as to what I could improve and what I could do better.

In the pastebin is my recover.c program, which recovers all images correctly, has no memory leaks and passes check50.

http://pastebin.com/PzRME6Lb

Thank you very much.

1

I think that your style is perfect.

In general its good practice to use sensible variable names where possible. This eliminates the need for comments at each instruction or decision. for the sake of an example: for a simple swap function in a sorting array you may write:

int t = a[i];
a[i] = a[i+1];
a[i+1] = t;

Which may need some comments for longer methods while

int temp_int = sorting_array[i];
sorting_array[i] = sorting_array[i+1];
sorting_array[i+1] = temp_int;

Will not need any comments.

Also try and keep your braces aligned, as you are doing and don't leave too much white space.

1
  • That's really good to hear. Thank you for your comments. I will try and have your advice in mind in the next psets. May 21 '16 at 8:17

You must log in to answer this question.

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