I wasn’t feeling too hot yesterday so I checked in sick. Slept most of the day and by the end of it, my back was sore because of how I slept – who knew that sleeping and rest could be so detrimental though in all honesty, it was good to rest up. I had a bit out of it since this run which seemed to coincide with something in the universe that slowed me right down, I don't know why but I think its because I been just doing way too much stuff and needed to rest. Sometimes as hard as it is, you need to stop, force yourself to stop else you will burn out.
Apart from that, I did go to the gym today however and i feel a lot better because of it – obviously I didn’t run/gym yesterday. In other news, I watched Donald Trump in action on youtube and thats pretty entertaining – especially as he exposes the biased and dishonest nature of the media at large – which I’ve always had a problem with. Remember this? For that I praise the guy for his determination and effort to expose it. The jury is out on all his other policies however but the guy’s growing on me honestly – if only for his, well frankness. So sue me, right?
Working on a few flaws in my word counting algorithm yesterday, which get exposed under Windows – Linux seems to handle the flaw well. Basically my unit test was failing and the problem was that I was doing some pointer arithmetic wrong – easily happens in C – probably why people tend to say that C is brutal because well it is. C# on the other hand or most other higher languages would be like ‘no, don't do that, don't move forward, don't collect £200 – sort that out now!’. C is like, ‘whatever man, you know what you’re doing right, you’re elite now right, you write C now? ok go for it”.
C is badass.
Here is what I did wrong, forget the other changes – that's just refactoring:
void STR_GetWordN(const char *s, unsigned int n, char* word)
{
int wc = 0;
- for(int i=0;i<strlen(s);i++)
+ printf("input string is '%s'\n",s);
+ for(int c=0;c<strlen(s);c++)
{
- if(isspace(s[i])) continue;
+ if(isspace(s[c])) continue;
wc++;
- while(!isspace(s[i])&&i<strlen(s)) {
+ do {
if(wc==n) {
- *word = s[i];
+ *word = s[c];
word++;
}
- i++;
- }
+ c++;
+ }while(!isspace(s[c])&&c<strlen(s));
if(wc==n) {
- word = '\0';
+ *word = '\0';
return;
}
}
I also figured that I could make this function shorter but nevermind that, lets get it working first – right Dennis Richie?
I took out a book on SQL the other day, – haven’t even read the first chapter. That tells me one thing for sure – take it back you don't want to read it. Rule #1 is to trust yourself.
I installed Visual Studio 2015 on my tablet yesterday, that took up 15GB of space – can you believe it. Long gone are they days it took up like 500MB. I want to develop more on my tablet because its lighter than my laptop and I love my laptop though.
I’m in this vortex in space and time right now where I’m not sure who I like the most right now Linux or Windows – I just like them both and that’s kind of a tough place to be because you can’t devote all your time to the one. Time is running out and you’ve got two options, I hate that. Linux to me is like the admirably, honest and loyal friend and windows is the boss that everyone likes including you. Go figure.
Life is a game of choices.