Declaring and Initializing String Variables in C | C Programming Tutorial for Beginners

preview_player
Показать описание

You can initialize a string as follows:
char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
A more convenient way to initialize the above string is
char greeting[] = "Hello";
You do not need to add the null to the end of string constants manually. The compiler does this for you automatically. Note that, if the string is initialized where it is declared, mentioning the string size is optional. A string can also be initialized and printed using normal scanf() and printf() functions respectively just like any other variable. Unlike arrays, we do not need to print a string, character by character. It has a format specifier “%s” which can be used to directly print and read strings. In this program, we'll demonstrate how to declare and initialize a string variable in C.

Hope you learn something new from this tutorial.

| -------------------------------------------------------------------- |

👍🏻 Subscribe to this Channel

► Introduction to Programming with C (2 hours of video content)

► Android Apps and Games Development for Beginners (12+ hours of video content)

► Android Game Development Tutorial in Android Studio (2+ hours of video content)

► Build a Complete Quiz App for Android

► Android SQLite Programming for Beginners (2.5 hours of video content)

► Android Game Development in Android Studio: Build Games for Absolute Beginners (3+ hours of video content)

► Android Game Development - Create Your First Mobile Game

► Android Game Development Tutorial

► Programming Flappy Bird for Android

► Object Oriented Programming Fundamentals

► jQuery for Beginner to Advanced

► PHP MySQL CRUD Tutorial (Create, Read, Update, Delete) (1+ hour of video content)

❤️ You can donate by clicking here. Thank you!

✉️ For Business Inquiries

📣 Follow me on other sites
Рекомендации по теме
join shbcf.ru