how to store a user input with spaces in 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;
}#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;
Also in C:
- pointer offset notation
- puts without newline c
- gcc on windows
- Write a C program to add negative values among N values using 2D array and pointer
- slurm array job
- ordenar un vector
- How to define Max in define in c
- how to ascii art in c
- program to concatenate two strings in c
- select all file from date powershell
- scanf integer
- atoi
- c number randomizer
- YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
- mode ouverture fopen
- c program to swap two arrays
- c print long
- how to globally initlailize a struct
- error: ‘sleep’ was not declared in this scope
- c zero out array
- how to make infinite loop in c
- _CRT_SECURE_NO_WARNINGS
- c unused variable
- CL/cl.h: No such file or directory