Table of Contents
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”;
char greeting[]=”Hello”; //Declaration and initialization char in C
Example of Strings
Declaration of String
Declare of a String in C Language two ways
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
When the above code is executed, it produces the following result
His name is kanthan
Example 2
When the above code executed, produced following result Enter youe name... Devid peris Your nane is Devid
Example character and pointer
kamalan
Multiply two numbers in Java using scanner| 5 different ways In this article, we will…
5 Different ways to Divide two numbers in Java using scanner In this article, we…
Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…
10 ways to subtract two numbers in Java In this article, we will discuss the…
Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…
How to Divide two numbers in Java| 5 different ways In this article, we will…
This website uses cookies.