Read String With Space C

[Solved] Read String With Space C | C - Code Explorer | yomemimo.com
Question : how to store a user input with spaces in c

Answered by : arjun-mair

#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;
}

Source : | Last Update : Sun, 14 Jun 20

Question : reading string with spaces in c

Answered by : defeated-dugong-04amxepr6y14

scanf ("%[^\n]%*c", name);

Source : https://stackoverflow.com/questions/6282198/reading-string-from-input-with-space-character | Last Update : Tue, 21 Sep 21

Question : how to store a user input with spaces in c

Answered by : arjun-mair

#include <stdio.h>
int main(){ char name[20]; printf("Enter a name : "); fgets(name, 20, stdin); // fgets(variable_storing_to, accepted_input_size, stdin) printf("the name entered is: %s\n", name);
return 0;

Source : | Last Update : Sun, 14 Jun 20

Question : read string with space c

Answered by : marton

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

Source : https://www.includehelp.com/c/c-program-to-read-string-with-spaces-using-scanf-function.aspx | Last Update : Sun, 24 Jan 21

Answers related to read string with space c

Code Explorer Popular Question For C