Monday, 30 October 2023

Chapter 27 // Exercise 13 - Principles & Practice Using C++

In this exercise I'm using Visual Studio 2022 and ISO C11 Standard.

Chapter 27 // Exercise 13

Write a program that does the equivalent of strings; cin >> s; in C; that is, define an input operation that reads an arbitrarily long sequence of whitespace-terminated characters into a zero-terminated array of chars.

I was a bit confused on this one as cin stop reading in characters when it encounters whitespace; have to use getline() to include the whitespace. So with the statement "define an input operation that reads an arbitrarily long sequence of whitespace-terminated characters" I decided instead he meant more of a getline() so we include whitespace characters. So if you were to type "this is a sentence", it captures the entire sentence and prints "this is a sentence". Maybe that's not what he meant though.

No comments:

Post a Comment