How To Get A String Input In C Code Example


Example 1: getting string input in c

#include<stdio.h> #include<conio.h> void main(){ chat sam[10]; clrscr(); printf("ENTER STRING NAME :"); gets(s); printf("STRING :%s",s); getch(); }

Example 2: Syntax To Take Input In C

Integer: Input: scanf("%d", &intVariable); Output: printf("%d", intVariable); Float: Input: scanf("%f", &floatVariable); Output: printf("%f", floatVariable); Character: Input: scanf("%c", &charVariable); Output: printf("%c", charVariable);

Example 3: input output string in c

#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h>  int main()  {      /* Enter your code here. Read input from STDIN. Print output to STDOUT */     char ch;     char s[100];     char p [100];     scanf("%c", &ch);     scanf("%s", s);     scanf("\n");     scanf("%[^\n]%*c", p);          printf("%c \n", ch);     printf("%s \n", s);     printf("%s", p);     return 0; }

Example 4: read string c

char name[20]; scanf("%s", name);

Example 5: how to get user input in c

#include <stdio.h> //this is for entering and storing strings int main(){     char name[20];      printf("Enter a name : ");     scanf("%s", &name);      printf("the name entered is: %s\n", name);    return 0; }

Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?