Advertisement
Guest User

Untitled

a guest
Mar 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. char * UserData[4] = { new char[50], new char[50], new char[13], new char[4] };
  2. char *** phoneBook = new char ** [10];
  3.  
  4. phoneBook[0] = UserData;
  5. gets(UserData[0]);
  6. gets(UserData[1]);
  7. gets(UserData[2]);
  8. gets(UserData[3]);
  9.  
  10. cout << phoneBook[0][2] << " Test string 1nn"; // Вывод стоки, здесь все хорошо.
  11.  
  12. phoneBook[1] = UserData;
  13. gets(UserData[0]);
  14. gets(UserData[1]);
  15. gets(UserData[2]);
  16. gets(UserData[3]);
  17.  
  18. // Вывод стоки, здесь всё хорошо.
  19. cout << phoneBook[1][3] << " Test string 2nn";
  20. // Значение перезаписалось! Почему?
  21. cout << phoneBook[0][2] << " Test string 1nn WHY IS IT CHANGING???";
  22.  
  23. phoneBook[0] = UserData;
  24. phoneBook[1] = UserData;
  25.  
  26. struct phoneBookStruct{
  27. char UserData0[50];
  28. char UserData1[50];
  29. char UserData2[13];
  30. char UserData3[4];
  31. }
  32.  
  33. phoneBookStruct phoneBook[10];
  34.  
  35. gets(phoneBook[0].UserData0);
  36. gets(phoneBook[0].UserData1);
  37. gets(phoneBook[0].UserData2);
  38. gets(phoneBook[0].UserData3);
  39.  
  40. cout<<phoneBook[0].UserData0<<" Testing"<<endl;
  41.  
  42. gets(phoneBook[1].UserData0);
  43. gets(phoneBook[1].UserData1);
  44. gets(phoneBook[1].UserData2);
  45. gets(phoneBook[1].UserData3);
  46.  
  47. cout<<phoneBook[1].UserData0<<" Testing"<<endl;
  48.  
  49. phoneBook[0] = UserData;
  50. phoneBook[1] = UserData;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement