Stats

729 Contributors: 28 Tuesday, March 28, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Strings

Introduction

In C, a string is not an intrinsic type. A C-string is the convention to have a one-dimensional array of characters which is terminated by a null-character, by a '\0'.

This means that a C-string with a content of "abc" will have four characters 'a', 'b', 'c' and '\0'.

See the basic introduction to strings example.

Syntax

  • char str1[] = "Hello, world!"; /* Modifiable */
  • char str2[14] = "Hello, world!"; /* Modifiable */
  • char* str3 = "Hello, world!"; /* Non-modifiable*/

Related Examples