You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of messing around with the get_string macro, and having one definition inside cs50.c and another definition everywhere else, the cs50 code should demonstrate good knowledge of the C programming language and its larger ecosystem by implementing get_string in the same way as the C Standard Library implements fprintf:
there's fprintf, which takes varargs and behaves as if it calls vfprintf internally.
there's vfprintf, which takes a va_list as argument.
This makes the code much cleaner and gets rid of the confusing macro. Remember, your students will look at that code and will use it as a role model, and if they later learn that your code style is bad, they will mistrust you in everything else you taught them, and rightly so.
The text was updated successfully, but these errors were encountered:
Instead of messing around with the
get_string
macro, and having one definition inside cs50.c and another definition everywhere else, the cs50 code should demonstrate good knowledge of the C programming language and its larger ecosystem by implementingget_string
in the same way as the C Standard Library implementsfprintf
:fprintf
, which takes varargs and behaves as if it callsvfprintf
internally.vfprintf
, which takes ava_list
as argument.This makes the code much cleaner and gets rid of the confusing macro. Remember, your students will look at that code and will use it as a role model, and if they later learn that your code style is bad, they will mistrust you in everything else you taught them, and rightly so.
The text was updated successfully, but these errors were encountered: