How can i store two string into an array ? I know the following code doesnt work. How can i modify the code so that it is able to store both the string in array form.
Code:arrayx[0] = "abc"; arrayx[1] = "def";
How can i store two string into an array ? I know the following code doesnt work. How can i modify the code so that it is able to store both the string in array form.
Code:arrayx[0] = "abc"; arrayx[1] = "def";
Assuming your array was declared as
OrCode:char arrayx[2][string_size];
Where each element is dynamically allocated the proper amount of space:Code:char *arrayx[2];
Don't forget to include string.h.Code:strcpy ( arrayx[0], "abc" ); strcpy ( arrayx[1], "def" );
My best code is written with the delete key.
Or:
Code:char* arrayx[] = { "abc", "def", "ghijkl" };
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.