fork download
  1. #include <iostream>
  2. using std::cout, std::cin, std::endl;
  3.  
  4. int main()
  5. {
  6. unsigned int maxim{100}; // задаем максимальную длину строки
  7. char string[maxim];
  8. cout << "please, enter the text: ";
  9. cin.getline(string, maxim);
  10. unsigned int counter{};
  11. for (; counter < maxim && string[counter] != '\0'; counter++) {}
  12. cout << "Length of your string equal: " << counter << endl;
  13. for (int i{}; i <= counter; i++)
  14. {
  15. cout << string[counter - i];
  16. }
  17. cout << endl;
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
please, enter the text: Length of your string equal: 0