## Ongoing notes

• how to enter the interactive mode? the main function for interactive mode is process_args. Like the code snippet below, it keep reading inputs from stdin(then using fgets to feed it into a input buffer), then using tokenize function(making use of strtok to tokenize the input commands), then the input command is stored in char ** cmdargv, which just like argv we often use. cmdargv[0] stores the first command, like profile and so on. What is left is just to depend on the return value from each core functions to display a proper information back to the screen.
• cast type when allocating memory for Fixed length character array

we need to do this:

to be able to allocate the memory for that character array.

• how to handle structs of linked list when only the head of the list is given like int create_user(const char *name, User **user_ptr_add). Note that since we will modify the linked list itself, we will have to pass in a pointer of pointer. Now if we only want to iterate through this linked list, we don’t need the ptr of ptr. Resolved by referring to this post , and refer to this post and this post from Geeksquiz for deleting a node from a post.

one key thing of dealing with ptr of ptr in linked list is that we need make clear the use of curr pointer and *user_ptr since we are suppore to change it in function int create_user(const char *name, User **user_ptr_add).

• type is not assignable during malloc: struct user *friends[MAX_FRIENDS];

• segmentation fault!!! Usually in practice, if we want to access the memory location where we don’t have access to, meaning that when we want to set some attributes, we need to first make sure that that part of memory has been malloc!!

One trick on this is to make sure that whenever we see a struct like this: first is to malloc memory for the all struct, then for each array, like here name, profile_pic and friends array. Especially the friends array, the haunting time when debugging for the final function delete_user, I always get a segmentation fault, which results from that I did not malloc the memory for the friend array at the very first beginning inside create_user function, thus when I try to change one element’s value, I will access to unallocated memory, a segmentation fault.

• Difference between memcpy and strcpy. strcpy will stop when meeting a ‘\0’ line terminator, while memcpy will not do that, it can do the content copy without looking to the value of the contents.

## Bugs remaining to fix

• time.h. I finally do a trick to cover up the failure of using time.h. we are supposed to record the time when a post is created, and store the address of that time_t, which is actually a long int, to the struct attribute post->date, while it fails to display the right time when doing ctime in print_user function. I finally insert a time update right into the print_user function to let them next to each other and it display right result?!.