0

I am just wondering, so far in the psets, we have been working closely with cs50.h library.

In real life though, there won't be much use for the cs50.h library, so my question is:

What is the equivalent of get_string, get_int, get_char,.... or what are the codes that function the same on a real C code (assuming that we don't import cs50.h)?

1

As one can see on https://github.com/cs50/libcs50/tree/master/src those contain quite some code to keep you from messing up and provide a nice user interface.

The simplest alternative would be scanf, which when used in a wrong way can easily lead to security problems ("buffer overflow") or wrong interpretation of results. It's also not always exactly intuitive what scanf covers, and in which state it leaves your file/input stream.

While the CS50 reference on scanf claims the cs50.h functions are based on scanf, it doesn't seem that way any more.

1
  • Definitely helpful, that src code link. Thank you!!!
    – Ha Tran
    Jun 21 '17 at 8:03

You must log in to answer this question.

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