Quote Originally Posted by Obvious Guy
I don't quite understand what you mean when you said I should be calling strcspn separately
Where should I call it?
That's because I had in mind comparing with strlen: it would be easier to see that way since you can name the variable so the reader knows why it is compared to strlen. But if you're comparing with the null character, which indeed would be more efficient, embedding it into the index notation is fine.

Looking at Hodor's edit, I think you were trying to use strspn for the other way: check to see if the list of invalid characters matches with an input character.

Quote Originally Posted by Obvious Guy
buffer[i] should have the first string in the file if i = 0
You were using *buffer all the way; why use buffer[i] now?

My suggestion is to rename the buffer parameter to output. Then, declare a local variable named buffer of type char* instead of char**. This will help you think more clearly in terms of a buffer of char. At the end of the function, just assign buffer to *output.