Advertisement
Ultimga

Untitled

Sep 12th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. string myName;
  2. // string myName = "";
  3. // string myName = "Bob";
  4. // string myName = NULL;
  5.  
  6. void main()
  7. {
  8. SetPlayerName( GetPlayerName() );
  9. }
  10.  
  11. string GetPlayerName()
  12. {
  13. // NOTE: Console::ReadLine() is a built in C++ function that waits for the user to enter text into the cmd console then press enter. this function gets the stuff they wrote as a return result.
  14.  
  15. string tempString = Console::ReadLine();
  16. myName = tempString;
  17. return myName;
  18.  
  19. // another way
  20. myName = Console::ReadLine();
  21. return myName;
  22.  
  23. // another way
  24. return myName = Console::ReadLine();
  25.  
  26. // best way
  27. return Console::ReadLine();
  28. }
  29.  
  30. void SetPlayerName(string _name)
  31. {
  32. myName = _name;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement