Home » Uncategorized » Initialization of string in C

Initialization of string in C

Following is a demo tutorial for initializing a string in C. This tutorial is meant for beginners and has a very simple syntax to try.

Do try out both the methods mentioned below!

#include <stdio.h>

int main(void) {
	char message[] = {'H', 'E', 'L', 'L', 'O', '\0'};
	printf("string is : %s\n", message);

	// Another way of initialising same string is as below,
	// char message[] = "HELLO";
	// note here, we dont need to mention "null" character '\0'
	// and this is most standard way to initilise strings

	return 0;
}

We hope this tutorial is of help. In case you have any other suggestions or questions, do let us know in the comments!

How To Print Integer In C With Sour...
How To Print Integer In C With Source Code Free Download 2020 | C Projects with Source Code

Leave a Comment

Sign up to our newsletter!