Thursday, July 9, 2009

Strings and arrays in c programming?

i am using the borland compiler and using c programming not c++ i was wondering how to create a four element array of strings to hold the suit's of a deck(hearts,spades, clubs, and diamonds). Thank you

Strings and arrays in c programming?
Ever use pointers?





const char *suits[4] = {"hearts","spades","clubs","diamonds"};
Reply:char *suits[]={{"hearts"},{"spades"},{"clubs"...


//to get hearts string use *suits, to get spades string use *(suits+1)
Reply:use pointers or use two dimensional array of char type


char ch[4][9]={"hearts","clubs","spades","dia...


here 9 is the maximum of length of string in the array ie.."Diamonds"


No comments:

Post a Comment