so you may have guessed from the title that this is Exercise 1-21 of K&R (2nd edition).
I’ve seen someone else’s post about it but it doesn’t solve the problem the way my code does, and I wasn’t sure whether I was allowed to post my code as an answer and ask for feedback (it just seemed better to create a new thread and ask for advice here, didn’t wanna pollute the other user’s topic but if that’s what I am supposed to do please let me know and I’ll reply over there).
In any way, here’s the approach I took to solve the problem:
We’ll keep track of number of spaces encountered (between nontab/nonspace characters)
We’ll keep track of characters (that aren’t tabs/blanks/newlines) per input line
We’ll evaluate the “gaps” generated by spaces by:
Evaluating whether the number of spaces in between those characters.
A gap will be “big enough” when the number of spaces is >= TABSIZE
Then, for all the left over spaces in our “buffer”, we’ll print them out individually
Finally, we print out the character that was read in (which was not a tab/blank)
As well as updating space count and character count if necessary.
Here’s the Gist on my Github profile, looking forward to hearing improvements to it!
Also, keep in mind that I am just revisiting C’s K&R and I am aware that some of it may be outdated, but I’m doing my best to use what’s still “useful” of the book and discard what may not be.
I’m using these notes to accompany my travels through C.
If anyone knows of any good resources such as the notes above, or has any feedback whatsoever on either the code/resources, please share it!
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!