fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. int main()
  5. {
  6. const int LEN = 3;
  7. const int n = 15;
  8. const char *s[LEN] = {"music", "disc", "soft"};
  9. char (*str)[n] = new char[LEN][n];
  10.  
  11. for(int i = 0; i < LEN ; i++) {
  12. strncpy(str[i], s[i], n);
  13. }
  14. for(int i = 0; i < LEN ; i++)
  15. std::cout << str[i] << std::endl;
  16.  
  17. delete []str;
  18. }
  19.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
music
disc
soft