In my code:
scanf("%s", &text); printf("%s\n", text);
Input:
hi how are you
Conclusion:
hi
but not
what can i do to fix this?
Take a look at fgets
The fgets () function reads no more than one less than the number of characters given n from a given stream and saves them in line s. Reading stops when a new line begins at the end of a file or an error occurs. A new line, if any, is retained. If any characters are read and there is no error, the `\ 0 'character is added to end the string.
I assume you are looking
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
. , -
ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
Use fgets to get your input:
#include <stdio.h> #include <stdlib.h> int main(void) { char text[80]; fgets(text, sizeof(text), stdin); printf("%s\n", text); }
Source: https://habr.com/ru/post/1776746/More articles:ReportViewer - ReportParameter - namespace WinForms vs WebForms - reportviewerHow to track where the appearance of the accessory on the right callout is when it was used - objective-cWhat exactly does the Response.Redirect ("~ / ...") response put in the HTTP response? - c #Check for flowLayoutPanel in C # - nullI get a StackOverflowException error in my nested class with given function of C # property - c #WebBrowser SetAttribute does not work (Password field) - c #Display and retrieve QMessageBox result from outside QObject - qtjquery parseFloat, parseInt - jqueryUnable to get basic Selenium + Capybara + Cucumber to work with Rails 3 - ruby-on-rails-3Ubuntu: Flash video in full screen - firefoxAll Articles