How to Define String in C?

Use a character array terminated by the null character `’’`

Example: `char str[] = “Hello”;`

Example: `char str[6] = {‘H’, ‘e’, ‘l’, ‘l’, ‘o’, ‘’};`

Use a pointer to a string literal

Example: `char *str = “Hello”;`

Use `const char *` for read-only string literals

Example: `const char *str = “Hello”;`

Use `#include ` for string handling functions

Use `#include ` for input and output with strings

Suggested for You

Trending Today