Strings as Input

Taking strings as input from the console

There are three standard ways to take a string as input from the console.

1. In the form of letters

In the first one, we take an ordinary integer array. We make a loop and keep taking the input character by character until the stream reader (cin) reads the delimiter character (which the user can define by themselves), for example, in the below code, we considered '.' as delimiter).

The cin>>achar does not read any of the following characters:

  • ' '
  • \t
  • \n
  • \r

Get hands-on with 1200+ tech skills courses.