logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/cs256su21code/jun29/arrayStrings.c

/*

if you want an array of strings, this is how you set that up

*/

#include <stdio.h>

int main(){

	char word[] = "dog"; //a simple character array

	char *words[] = {"cat", "mouse", "bird", "ferret", "possum"};
	/*
	  to make an array of strings, you have to put the * symbol in front
	  of the name of the array declaration.
	*/
	printf("%s\n", word); //printing the character array

	//iterating through the array of strings
	for(int i = 0; i < 5; i++){
		printf("%s\n", words[i]); //refer to it like a normal array to get the string stored
								  //at that index

	}

	return 0;
}