read string with space c

#include <stdio.h>

int main(){
    char name[20];

    printf("Enter a name : ");
    scanf("%[^\n]%*c", &name);

    printf("the name entered is: %s\n", name);

return 0;
}

5
1
Awgiedawgie 440220 points

                                    #include &lt;stdio.h&gt;

int main(){
    char name[20];

    printf(&quot;Enter a name : &quot;);
    fgets(name, 20, stdin); // fgets(variable_storing_to, accepted_input_size, stdin)

    printf(&quot;the name entered is: %s\n&quot;, name);

return 0;

5 (1 Votes)
0
3.6
5
Awgiedawgie 440220 points

                                    char name[30];
char temp;

printf(&quot;Enter age: &quot;);
scanf(&quot;%d&quot;, &amp;age);
printf(&quot;Enter name: &quot;);
scanf(&quot;%c&quot;, &amp;temp); // temp statement to clear buffer
scanf(&quot;%[^\n]&quot;, name); // read until newline

3.6 (5 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
c input string with spaces HOW TO take string with space in c take spaces as input in c string how to take the input with space in c c string input with spaces scanning string with spaces in c read string with space character in c read string with spaces c printing a string with spaces in c how to read space in string in C c read string with spaces from file read spaces in c take input in space c read string with spaces in c How to take input in C with spaces take space from string c how to take string input with spaces in c reading a string with spaces in c take string input in c with spaces c print string with spaces how to make input process spaces in C how to accept a input with spaces in C how to take inputs in c with spaces c read a string with spaces how to read a string in c with space take string with space in c how to store user input with spaces in c how to read a string with spaces from keyboard in c how to get a string with spaces in C string with space in c c best way to read string with spaces space input in c how to take integer input with spaces in c how to get string input with spaces in c c read input with spaces string with spaces input in c print string with spaces in c how to read a string with a space in c read string by whitespace c c get string with spaces how to get string with space in c how take string with space in c how to accept space in string in c how to get space as input in c take input of string with spaces in c read string with spaces c read string with spaces input space in c how to take input string with spaces in c read a string with spaces in c hoqw to scan space in c c name with space space in c string c input long string with spaces string space in c how to read a string with spaces in c\ how to input a string with spaces in c how to read in string with space in c c scan line including whitespace how to take input string values in c how to get string input in c how to take string line input in c how to print string with spaces in c using scanf how to get a string user input in c get input with space in c how to take string input in c with spaces get string in c how to print string in c with spaces c string with space how to include whitespace in string input c c input function which can take whitespace c take strin with space how to read space in c how to input string with spaces in c using scanf how to read space separated string in c to take a string input how to read a string with spaces in c c input with spaces inputting strings in c accept string in c how to input string with spaces in c getting a string with spaces from user c c accept string input with space read variable accept spaces how to take input in c with whitespace in betwween read string with space c scanning strings with spaces in c getting string inputs in c using space to take input scanf how to get a string in c with space input-space c scan string with space in c how to take input int c with whitespace in betwween how to read string with spaces in c c get input and immediately print to same space scanning complete string in c take input string with space in c input string with spacein c take input of string with space in c how to save a string in c with spaces read string with spaces with scanf how to get two strings with spaces in c how to store a string with spaces in c read input with spaces in c input a word with spaces in c how to scan string with spaces in c input string in c with spaces read line with spaces in c how to include spaceds when inputting strings in c get string with space c get string with spaces in c take input with spaces in c take input from user with spaces in c string with spaces as input c stdin string with space how to input string with whitespace characters in c how to take input as strings taking in a string %c input with spaces in c hwo to read a string space how to take input with spaces in c c scanner input with spaces how to take string as aan input c how to input a string with spaces input string with spaces in c how to read string input in c without \n scanf c string with spaces input space containing strings taking string input with space in c how to read in a string with spaces in c take string input with spaces in c string in c with space input string c with spaces string input in c with space scanf string with spaces c get string with space in c how to accept string from user in c string input in c with spaces c program to take space in a string how to scan strings for spaces in c accept string c with space input string from user in c input string in c string gets space character c c how to read a string with spaces how to take input string in c how to store a user input with spaces in c
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source