====== Lab04 - Strings and (de)allocation ====== ==== Valgrind ==== * use ''valgrind'' for memory leak detection * can detect forgotten allocated memory and the exact location of out-of-bound access * can report using uninitialized variables/memory * for better output, compile your program with ''-g'' flag * ''valgrind ./your-program'' ==== Documentation ==== * [[https://en.cppreference.com/w/c]] * learn to understand the function declaration (the name, return type, and parameters) * the definition (code to be executed) might not always be available ==== Strings ==== * Remember you can use ''#include '' for helper functions * Let's declare an array of characters, and then ask the user for their first name * Print the name, its length, and say if it's the same as your own name * You can use the function ''strcmp'' to compare the strings, will return zero if the same ==== Dynamic memory ==== * Modify your program to use dynamic memory for the name * Ask the user for other names * Use ''realloc'' to make the original name string bigger * Use ''memcpy'' to append the additional name to the original name/string