Advertisement
avr39ripe

PV024strEnter

Dec 24th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     int arr[]{ 1,2,3,4,5 };
  6.     bool barr[]{true,false,false,true};
  7.     char str[]{ "Hello, this beautiful world!" };
  8.     char inStr[30];
  9.     //char* chPtr{new char[200]};
  10.  
  11.  
  12.  
  13.     //return 0;
  14.  
  15.     //std::cout << "Enter some string: \n";
  16.     //std::cin >> inStr; //1 "Hello, world!"; 2" world!\n"
  17.     //std::cout << inStr << '\n';
  18.  
  19.     //std::cin >> inStr; //1" world!\n"
  20.     //std::cout << inStr << '\n';
  21.  
  22.     //delete[] chPtr;
  23.     int a{};
  24.     int b{};
  25.  
  26.  
  27.     std::cin >> a; //"\n"
  28.  
  29.     std::cin >> b;
  30.  
  31.     std::cout << "a = " << a << " b = " << b << '\n';
  32.  
  33.     std::cin.ignore(300,'\n');
  34.  
  35.     std::cout << "Enter some string: \n";
  36.     std::cin.getline(inStr,30);
  37.     std::cout << inStr << '\n';
  38.  
  39.    
  40.     /*std::cin.getline(inStr, 30);
  41.     std::cout << inStr << '\n';*/
  42.  
  43.     return 0;
  44.  
  45.     //for (int i{ 0 }; *(str + i); ++i)
  46.     for (auto outStr{str}; *outStr; ++outStr)
  47.     {
  48.         std::cout << *outStr;
  49.     }
  50.     std::cout << '\n';
  51.  
  52.  
  53.  
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement