Categories: C LanguageLearn C++

String Handling in C Programming Language

String Handling in C Programming Language

In this tutorial, we will discuss the concept of String Handling in C Programming Language.

 

In this tutorial, we will explain String handling and their operations ic C language. We have to handle String in C language using character array because there is no special data type for String in C language. The array of characters or set of characters can be called String in C.

char is one of the variable types in C language that contains a single character. But, the set of character is also known as an array of character represents a string in C language.

The array of characters are terminated by a null of character “n”;

Memory presentation of string in C using char array

char greeting[]=”Hello”;  //Declaration and initialization char in C

character array

String manipulation

Example of Strings

  • Name of the person
  • Address of the house
  • Name of items

Declaration of String

Declare of a String in C Language two ways

  1. Using an Array
  2. Using a Pointer

Using an Array

    Diclaration                                                                                                                                       

Syntex

char c[];

or

char c[25];


Initialization of String                                                                                                                      

char c[]=”kanthan”;

or

char c[20]=”kanthan”;

or

char c[]={‘k’,’a’,’n’,’t’,’h’,’a’,’n’}

or

char c[7]={‘k’,’a’,’n’,’t’,’h’,’a’,’n’}

Using Pointer

    Declaration and Initialization of String

Syntex

char *c=””kanthan;;

Example 1

Example

When the above code is executed, it produces the following result

His name is kanthan

Example 2

Example
When the above code executed, produced following result

Enter youe name...
Devid peris

Your nane is Devid

Example character and pointer

 

Example
When the above code was executed, it produced the following result
kamalan
Suggetsed for you

 

Karmehavannan

Recent Posts

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

11 months ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

11 months ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

11 months ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

11 months ago

Function/method to convert Celsius into Fahrenheit -Entered by user

Function/method to convert Celsius into Fahrenheit -Entered by user In this article, we will discuss…

11 months ago

Temperature conversion: Celsius into Fahrenheit using function or method

Temperature conversion: Celsius into Fahrenheit using a function or method In this article, we will…

11 months ago

This website uses cookies.