ADVERTISEMENT
ADVERTISEMENT

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

ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.