title: How to remove newline from dynamic strings
body: <p>I have this segment of code which takes in input various strings. They don't have to have newline in the end, I need them one next to another because I'm writing them on a CSV file. I put this on a while</p>
  
  <pre><code>    do {
          printf("Put the ingredient:\n");
          fgets(recipe.ingredients[j], 30, stdin);
          len = strlen(recipe.ingredients[j]) + 1;
          recipe.ingredients[len] == "\0";
          fprintf(fbr, "%s,", recipe.ingredients[j]);
          j++;
          counter++;
          printf("Do you want to continue? (yes/no)");
          fgets(sentinel, 4, stdin);
      } while(strcmp("yes", sentinel) == 0);
  </code></pre>
  
  <p>The problem is, the first string I get in input doesn't have the newline char since I put that condition. I tried both adding and subtracting <code>1</code> to the length but in both cases I have just the first string without the newline and the others have the newline anyway. I thought that by replacing the newline character with the null terminator I would solve my problem but maybe I'm missing something. Any hint to solve this? I'm a bit confused...</p>