Stripping newline is being very tricky
<p>It looks like scanf() is reading the previous '\n'. I'm trying to get my concatenated string on one line. How do I get rid of the '\n' at the beginning of my second string. </p>

<p>This is a c program.</p>

<p>I'm guessing I have to flush the buffer somehow BEFORE the next line is read in. But I don't know how to do this without an error.</p>

<p>Btw, I cannot use cin.get() or other standard cin/cout operations here. I also cannot use standard string operations, because I'm working exclusively with c-strings and strings.h, not string.</p>

<p>input from stdin is:</p>

<p><code>12
 4.0
 Spot run!</code></p>

<pre><code>int main() {
    int i = 4;
    double d = 4.0;
    char s[] = "See ";

    int isum;
    int MAX_SIZE = 256;
    double dsum;
    char s2[MAX_SIZE];

    scanf("%i",&amp;isum);
    scanf("%lf",&amp;dsum); // Hope to clear out the newline from reading 
                        // in the double value. Or any other newline 
                        // before the next scarf(), but haven't figured
                        // how.
    scanf("%79c", s2); 

    isum += i;
    printf("%d \n",isum);

    dsum += d;
    printf("%.1f \n",dsum);

    char newchar[MAX_SIZE];
    strcpy(newchar,s);
    newchar[strcspn(newchar,"\n")]='\0';
    s2[strcspn(s2,"\n")] = 't'; //To test where newline is in second string.
    strcat(newchar,s2);
    printf("%s",newchar);

    return 0;
</code></pre>

<p>My output is:</p>

<p><code>16 
 8.0 
 See 
 tSpot run!</code> //&lt;--note the 't' in front of Spot!!!</p>