I have pasted my .cpp code below, my goal is removing the whitespace from my .txt file. Is someone able to provide suggestions and help me figure this out?
Doesn’t fgets put the string into that buffer variable? I would expect your function needs to take the buffered string and handle that. Also, not sure if you need to clear the buffer between reads.
Your approach is fine. But you need to either use const char *char_pointer or std::string in both reading and processing of text.
In main, you have used const char *char_pointer, while in string solve(string) there is a string parameter. They are not compatible.
Either change the string parameter in string solve(string) to FILE * (which is discouraged in C++) or read your file using ifstream object from fstream header.
Mosh has explained using fstream objects in Streams and Files module in part 2 of C++ course.