Home / Programs / String in C Example
Programming Example

String in C Example

👁 1,010 Views
💻 Practical Program
📘 Step by Step Learning
String in C Example

Program Code

/* 
 
Author: Atnyla Developer

*/

#include<stdio.h>
 
int main ()
{
  char string1[11] = {'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd', '\0'};
   char string2[11] = "helloworld";
   char string3 []  = "helloworld"; 
 
   printf("The string is : %s \n", string1 );
   printf("The string is : %s \n", string2 );
   printf("The string is : %s \n", string3 );
   return 0;
}

Output

The string is : helloworld
The string is : helloworld
The string is : helloworld
Press any key to continue . . .

Explanation

String in C Example

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.