Introduction
Given a sentence, s
, print each word of the sentence in a new line.
Input and Output Format
|
|
{: file="Input and Output” }
Process
This was a pretty simple challenge. Completing the code, I’ve added a for loop to print each character at a time, scanning for any blank spaces and “replacing” that with a newline escape character \n
.
Code
|
|
{: file="Printing Tokens.c” }
Afterthoughts
Looping through each character in the string, a check is done to check for blankspaces and replacing them with a newline character.
I did it using an ordinary for loop but translated that same loop to a ternery operator for elegance. I really like the use of ternery operators in C.
This challenge earned me 20 points!