In this exercise I'm using Visual Studio 2022.
Chapter 27 // Exercise 9
Using only C facilities, including the C standard library, read a sequence of words from stdin and write them to stdout in lexicographical order. Hint: The C sort function is called qsort(); look it up somewhere. Alternatively, insert the words into an ordered list as you read them. There is no C standard library list.
Github: https://github.com/l-paz91/principles-practice/blob/master/Chapter%2027/Exercises/Exercise%209.c
I could not get EOF to work in the slightest with scanf and ctrl+z. I decided to go with the qsort approach because no thank you to the list, so you have to enter the max amount of words to get it to quite the loop. Sometimes it would register the EOF, sometimes it wouldn't, sometimes I had to spam it on the keyboard and it would eventually register it.
No comments:
Post a Comment