Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. Arrays and Strings
  5. Strings

Strings

In C programming, array of character are called strings. A string is terminated by null character /0

Example

COMPUTER PROG
COMPUTER PROG\0

Here, “COMPUTER PROGl” is a string. When, compiler encounters strings, it appends null character at the end of string.

Declaration of Strings

Strings are of char type

char arr_name[arr_size];

Example

char s[5];

Here, s is name of array

Initialization of Strings

In C, string can be initialized in different number of ways.

char c[]="abcd";
     OR,
char c[5]="abcd";
     OR,
char c[]={'a','b','c','d','\0'};
     OR;
char c[5]={'a','b','c','d','\0'};

String Operations

Strings handling functions are defined under "string.h" header file

Views: 0

Articles

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments