Programming has many special symbols and keywords. Of them, we need to remember a lot of keywords. In this blog, we are going to learn about %s in C.
The string is a set of characters. We use %s as a format specifier for a String. A string is defined by an array and a String is enclosed inside double quotes. Let’s take a look at an example to understand %s uses.
#include <stdio.h>
int main()
{
// Creating a String
char name[20];
printf("Enter name: ");
// Getting String Value from user
scanf("%s", name);
// Printing String
printf("Your name is %s.", name);
return 0;
}
In this example, %s is used two times. In scanf %s is used to get the string value from the user. In printf %s is used to print the value of the string entered by the user.
I hope you all enjoyed this tutorial about String format specifiers in C Programming. For any further queries just comment below and join our Telegram channel also. Wish you all a happy coding journey!