Recent Posts

Friday, 7 December 2018

What is String

String:

  1. String is a collection of two or more characters.
  2. In string we can store alphabets digits and special symbols.
  3. when we declare array of character type then it is called as string.
  4. In C, character type array is used to store a string.

Declaration of String:
The declaration of string is similar like Array.
for declaring string we need to specify its size means maximum of how many characters we have to store in string.

Syntax: char string[size];
Example: char str[20];

Here we declare a string variable str of size 20 means variable 'str' characters.

Initialization of String:
while declaring string we can also initialize some value at the time of declaration.

Syntax: char string[size]="text";
Example: char str[20]="programmingsolution";

Here we declare a string variable 'str' of size 20 and assign programmingsolution to it.

Inputting string:

To input the content in the string two function used as 'scanf()' and 'gets()'.
In 'scanf()' function spaces are not allowed in a string.if we give space then the remaining part will be truncated from string.
In 'gets()' function spaces are allowed in a string.

Syntax:    scanf("%s",string_variable);
                 gets(string_variable);
Example: scanf("%s",str);
                 gets(str); 


Related Posts:

  • Variable If you want to learn programming you must know variable, constant, keywords ,data type and operators in C language.In the p… Read More
  • What is String String: String is a collection of two or more characters. In string we can store alphabets digits and special symbols. when we declare array of ch… Read More
  • String function In the previous post we learn about what is String.we know that string is a collection of two or more characters.In string we can store alphabet, dig… Read More
  • Difference between compiler and interpreter C is a general purpose programming language.In the previous post we learnt about what is high level language and what is low level language. … Read More
  • 2d array in C In the previous post we learn about what is array and what is one dimensional array.In this post we will learn what is two dimensional array. What … Read More

0 comments:

Post a Comment

Followers

Popular Posts

Categories

social media

Text Widget

Powered by Blogger.

About Me

My name is junaid khan and i am a full time blogger and author of a blog tutorial called tutorialpointsolution.

String function

In the previous post we learn about what is String .we know that string is a collection of two or more characters.In string we can store al...

Search This Blog

Technology

Adbox

Recent Post

Breaking

Recent In Internet

Comments

Facebook

Pages

Comments

Pages

Recent

Pages

Technology