diff --git a/src/io.cpp b/src/io.cpp index 90f2791..c8a8734 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -40,3 +40,15 @@ void print_type_size_bytes() std::cout << std::setw(16) << "double:" << sizeof(double) << " bytes\n"; std::cout << std::setw(16) << "long double:" << sizeof(long double) << " bytes\n\n"; } +void string_demo() +{ + using namespace std; + cout << "Enter your full name: "; + string name{}; + getline(cin >> ws, name); + cout << "Enter your age: "; + int age{}; + cin >> age; + int letters{static_cast(name.length())}; + cout << "Your age + length of name is: " << (letters + age) << "\n"; +} \ No newline at end of file diff --git a/src/io.h b/src/io.h index ecdefe3..74cc367 100644 --- a/src/io.h +++ b/src/io.h @@ -5,3 +5,4 @@ int read_number(); void write_answer(int x); void convert_char_to_ascii(); void print_type_size_bytes(); +void string_demo(); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 0a793a6..b0c8dde 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,7 @@ int main() { + // string_demo(); // add_two_numbers(); // convert_char_to_ascii(); print_type_size_bytes();