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.
Github: https://github.com/l-paz91/principles-practice/blob/master/Chapter%2027/Exercises/Exercise%2013.c
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