Delete line break when using fgets in c

0

when reading a string of characters with fgets, this also saves the line break (\ n), how can I delete that line break using fgets anyway to read? It does not help me to use fscanf or another format to read Thanks.

    
asked by Damiàn Ortega 20.06.2017 в 00:27
source

1 answer

1

When you read the character string with fgets , use strtok(cadena, "\n") to eliminate the line break. You can also delete the character directly by accessing the string as an array of characters.

    
answered by 20.06.2017 в 00:31