Arrays of strings : String Array « String « C Tutorial






#include <stdio.h>

int main(void)
{
  char str[][40] =  { "AAA",
                      "BBBBBBBB"
                    };
  int strLength[] = {0, 0};
  int i;
  for(i = 0 ; i<2 ; i++){
    while (str[i][strLength[i]])
      strLength[i]++;
  }

  if(sizeof str[0] < strLength[0] + strLength[1] + 1){
    printf("\nNo enough space");
  }else{
    strLength[1] = 0;
    while((str[0][strLength[0]++] = str[1][strLength[1]++]));
    printf("\n%s\n", str[0]);
  }
  return 0;
}
AAABBBBBBBB








3.10.String Array
3.10.1.Arrays of strings