C - Initialize Array of Strings in C, C Program for of Array of Strings.


IncludeHelp 03 September 2016

In this code snippet (Example) we will learn how to initialize, read and print array of strings in c programming language?

In this example we will declare array of strings or array of array of characters to initialize 3 strings; we will print them through a loop.

C Code Snippet - Initialize Array of Strings in C

/*C - Initialize Array of Strings in C, 
C Program for of Array of Strings.*/

#include <stdio.h>

int main(){	

		char string[3][30]={"String 1","String 2","String 3"};
		int loop;
		
		//print all strings
		for(loop=0;loop<3;loop++){
			printf("%s\n",string[loop]);
		}
		return 0;
}

    String 1
    String 2
    String 3




Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.