I need to get the last 2 characters from the last name which is input from the keyboard. I am trying to use "thestring.copy(str, x, n). I do not know the length of the name being input. my attempt at the function is
last.copy(str, strlen -2, 2)
I am using strlen - 2 to find the end of the string and copy from the last 2 characters. I do not know if I am on the right path and also I am getting an error
Rev 2.cpp||In function 'int main()':|
Rev 2.cpp|39|error: cannot convert 'std::string' to 'const char*' for argument '1' to 'size_t strlen(const char*)'|
Rev 2.cpp|54|warning: pointer to a function used in arithmetic|
Rev 2.cpp|54|error: invalid conversion from 'size_t (*)(const char*)' to 'unsigned int'|
Rev 2.cpp|54|error: initializing argument 2 of 'typename std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::copy(_CharT*, typename _Alloc::rebind<_CharT>::other::size_type, typename _Alloc::rebind<_CharT>::other::size_type) const [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'|
Rev 2.cpp|58|error: expected ';' before '}' token|
||=== Build finished: 4 errors, 1 warnings ===|