Remove whitespace from file

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?

#include <iostream>
#include <sstream>
using namespace std;
string solve(string s) {
   string answer = "", temp;
   stringstream ss;
   ss << s;
    while(!ss.eof()) {
      ss >> temp;
   return answer;
int main() {
   char buffer[100];
   FILE *fp = fopen("input.txt", "r");
   while (fgets(buffer, sizeof(buffer), fp))
     cout << solve(fp);
   return (0);

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.

Alternatively, can you use getline instead?