I would like to copy lines from stdin to an array of character pointers. For example if the user entered the following ‘the\nquick\nbrown\nfox’ then I would like to have an array that looks like
arr[0] = ‘the’ arr[1] = ‘quick’ arr[2] = ‘brown’ arr[3] = ‘fox’
Any pointers?
You would need to make sure you have allocated not only an array of pointers, but also allocated space for each of your elements. I am not checking for NULL pointers like you should be, but this should get you started.
afterwards, you’ll need to free that memory too: