fork(3) download
  1. #include <iostream>
  2. #include <cstring>
  3. #define T_SIZE 1001
  4.  
  5. char* string_merge(char *, char *);
  6.  
  7. int main()
  8. {
  9. char text[T_SIZE];
  10. char text2[T_SIZE];
  11. int how_many_step = 0;
  12. std::cin >> how_many_step;
  13. for ( int i = 0 ; i < how_many_step ; ++i )
  14. {
  15. int size_tab = 0;
  16. std::cin >> text >> text2;
  17. char* text_final = string_merge( text , text2 );
  18. for ( int i = 0 ; i < std::strlen(text_final) ; ++i)
  19. std::cout << text_final[i];
  20. std::cout << std::endl;
  21. delete[] text_final;
  22. }
  23. return 0;
  24. }
  25. char* string_merge(char *text, char *text2)
  26. {
  27. int size_tab_final = 0;
  28. int index = 0;
  29. if ( std::strlen(text) > std::strlen(text2) )
  30. size_tab_final = std::strlen(text2);
  31. else
  32. size_tab_final = std::strlen(text);
  33. size_tab_final *= 2 ;
  34. char* text_final2 = new char[size_tab_final];
  35. for ( int i = 0 ; i < size_tab_final ; ++i)
  36. {
  37. if ( i % 2 == 0 )
  38. text_final2[i] = text[index];
  39. else if ( i % 2 == 1 )
  40. {
  41. text_final2[i] = text2[index];
  42. ++index;
  43. }
  44. }
  45. return text_final2;
  46. }
  47.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'char* string_merge(char*, char*)':
prog.cpp:35:26: error: 'd' was not declared in this scope
     for ( int i = 0 ; i <d
                          ^
prog.cpp:36:11: error: expected ';' before 'size_tab_final'
           size_tab_final ; ++i)
           ^
prog.cpp:36:26: error: expected ')' before ';' token
           size_tab_final ; ++i)
                          ^
prog.cpp:36:30: error: 'i' was not declared in this scope
           size_tab_final ; ++i)
                              ^
stdout
Standard output is empty