Recently, on my way back home from school, I was thinking general thoughts about programming. One thing I was wondering is how to create a string array in C. Since a strings in C look like the following -
Quote
char *str1;//Pointer
char str2[];//Pointer
char str3[256];//Array
char str2[];//Pointer
char str3[256];//Array
Quote
char *strArray[5];//5 strings in an array
Quote
char *str[5];//5 strings in an array
char *p_str, *p_str2;
str[0] = "This is string number 1.";
str[1] = "This is string number 2.";
p_str = str[0]; p_str2 = str[0] + strlen(str[0]) + 1;
puts(p_str);
puts(++p_str);
puts(p_str2);
char *p_str, *p_str2;
str[0] = "This is string number 1.";
str[1] = "This is string number 2.";
p_str = str[0]; p_str2 = str[0] + strlen(str[0]) + 1;
puts(p_str);
puts(++p_str);
puts(p_str2);
Quote
This is string number 1.
his is string number 1.
This is string number 2.
his is string number 1.
This is string number 2.


Sign In
Create Account



Back to top









