fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <stdio.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string name[2] = {
  9. string("1234", sizeof("1234")),
  10. string("567", sizeof("567"))
  11. };
  12.  
  13. string list[] = {"A1", "A2"};
  14. string str = "";
  15. str.append("{");
  16. for (int i = 0; i < 2; i++) {
  17. str.append(list[i]);
  18. str.append(":");
  19. str.append(name[i]);
  20. str.append(",");
  21. }
  22. str.pop_back();
  23. str.append("}");
  24.  
  25. cout << "cout: " << str << "\n";
  26.  
  27. const char *s = str.c_str();
  28. cout << "send: " << s << "\n";
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 4528KB
stdin
Standard input is empty
stdout
cout: {A1:1234,A2:567}
send: {A1:1234