• 0 Posts
  • 55 Comments
Joined 3 年前
cake
Cake day: 2023年6月19日

help-circle











  • Before trying to learn and use the standard library, I’d advise you to write a few simple functions yourself:

    1. void print_until(const char* str, char c) - print every character in str until you see c or null (Note: Don’t print the c or null, which should ensure that a str that only contains a \0 doesn’t crash.)
    2. const char* print_until_2(const char* str, char c) - as before, but return the pointer to where you found c or null
    3. void print_delimited_by(const char* str, char delimiter, char separator) - use print_until_2 in a while-loop, don’t print the delimiter, but do print a separator.

    For example, print_delimited_by("1;2;3",';',',') should print 1,2,3.

    Finally, void num_delimited_by(const char* str, char del) - like print_delimited_by, but add a number before every output, and use newline as the separator.

    These fundamental string exercises will give you a solid foundation for understanding oantby’s explanations about the standard library. Note that no memory allocation is necessary.








  • Most of the “undecidable” are only undecidable for a subset of the problem instances, while a vast number of instances can be even trivially decidable. For example in the undecidable halting problem, both you and a computer can trivially deduce that while(true) will not halt. In the same way a computer can deduce that many instances of two pieces of code are semantically equivalent.

    I’d like to see an instance of the problem where a human could decide it and the computer could not.