C Program to Initialize and Print String

Write C Program to Initialize and Print String

// C Program to Initialize and Print String

#include <stdio.h>

int main()
{
	printf("There are total 4 ways to initialize string in c :--> ");

	char S1[]="CodeCrucks";

	char S2[45]="CodeCrucks";

	char S3[]={'C','o','d','e','C','r','u','c','k','s','\0'};

	char S4[45]={'C','o','d','e','C','r','u','c','k','s','\0'};

	printf("\n\nNo 1 :--> %s", S1);
	printf("\nNo 2 :--> %s", S2);
	printf("\nNo 3 :--> %s", S3);
	printf("\nNo 4 :--> %s", S4);

	return 0;
}

Output:

There are total 4 ways to initialize string in c :-->

No 1 :--> CodeCrucks
No 2 :--> CodeCrucks
No 3 :--> CodeCrucks
No 4 :--> CodeCrucks

≪ Previous | Next ≫