Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define internal vget_string helper function #176

Open
rillig opened this issue Aug 16, 2019 · 1 comment
Open

Define internal vget_string helper function #176

rillig opened this issue Aug 16, 2019 · 1 comment
Assignees

Comments

@rillig
Copy link

rillig commented Aug 16, 2019

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.

@rillig
Copy link
Author

rillig commented Aug 19, 2019

When trying out libcs50 in JetBrains CLion, the definition of the get_string macro produces this completion:

image

This is unnecessarily confusing and should be fixed by not needing the macro at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants