Pick up all text from a typed line

-2

I'm creating an algorithm in C to train myself and I need to get a text (large and with spaces) that the user types at the same prompt. I've tried using scanf, gets and fgets and none is catching what comes after the space, just the text until you get the first space. How can I get all the text and save in an array of char only?

char texto[3000];
fgets(texto, 3000, stdin);

My last attempt was this one, but it only takes the first word before space.

I can not get enter (line break) because there are more actions to take after getting the first text

    
asked by anonymous 03.07.2017 / 21:11

1 answer

3

I did this test here and he read the whole line. How are you checking the value read? It may be that the error is in this part.

See my code:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char texto[3000];
    fgets(texto, 3000, stdin);
    printf("%s", texto);

    return 0;
}
    
03.07.2017 / 21:49