bing
Flat 10% & upto 50% off + Free additional Courses. Hurry up!

C Strings

 

String is a collection of characters. It is a one dimensional array of characters.

There are two ways to declare string in c language.

  1. By char array
  2. By string literal

 

  • Declaring string by char array
char c[11]={'i', 'n', 't', 'e', 'l', 'l', 'i', 'p', 'a', 'a', 't' ,’\0'};

 

  • Declaring string by string literal
char c[]="intellipaat";

 

Example 

#include <stdio.h>

#include <conio.h>

void main ()

{

char c1[11]={'i', 'n', 't', 'e', 'l', 'l', 'i', 'p', 'a', 'a', 't' ,’\0'};

char c2[]="intellipaat";

printf("Char Array Value : %s\n", c1);

printf("String Literal Value : %s\n", c2);

getch();

}

Output

Char Array Value: intellipaatString Literal Value is: intellipaat

 

No. Function Description
1) strlen(string_name) Returns the length of string name.
2) strcpy(destination, source) Copies the contents of source string to destination string.
3) strcat(first_string, second_string) Concats or joins first string with second string. The result of the string is stored in first string.
4) strcmp(first_string, second_string) Compares the first string with second string. If both strings are same, it returns 0.

"0 Responses on C Strings"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.

top

Sales Offer

  • To avail this offer, enroll before 07th December 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer
offer-june

Sign Up or Login to view the Free C Strings.