Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input (what you will type in the console) = 'Get out'
- lastChar = '\0'
- In a while loop:
- 1 First time, c = 'G'. Is c a space? nope, is lastChar a space? nope, ok then just print 'G'
- 2 Second time, c = 'e'. Is c a space? nope, is lastChar a space? nope, ok then just print 'e'
- 3 Third time, c = 't'. Is c a space? nope, is lastChar a space? nope, ok then just print 't'
- 4 Fourth time, c = ' '. Is c a space? Yes! is lastChar a space? nope, ok let me make lastChar = ' ' and print ' '
- 5 Fifth time, c = ' '. Is c a space? Yes! ok is lastChar a space? Yes! ok then let's not print anything
- 6 Sixth time, c = ' '. Is c a space? Yes! ok is lastChar a space? Yes! ok then let's not print anything
- 7 Seventh time, c = 'o'. Is c a space? nope, ok is lastChar a space? Yes! ok make lastChar = '\0' and print 'o'
- 8 Eight time, c = 'u'. Is c a space? nope, ok is lastChar a space? nope, ok then just print 'u'
- 9 Ninth time, c = 't'. Is c a space? nope, ok is lastChar a space? nope, ok then just print 't'
- 10 Tenth time, c = EOF. Welp while loop ends here....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement