So, I wrote this program to decode Pig Latin (e.g : Input = "igpay atinlay." → final output = "pig latin." (Opposite of one of the CodeCoach problems)
I'm considerably new with C, and am finding string operations a real pain, and here, I have no clue as to why it's showing timeout error. Any help would be highly appreciated.
one problem i can spot is you're using sizeof as condition in for loop.
sizeof return a memory space of your variable, if its an array then the size times array size.
so lets say sizeof single char return 4, then whats the sizeof an array of 2000 char ?
so you're basicly looping for 8000times several times
sizeof(input) is not an issue.
sizeof(char) is 1 so sizeof(char array) will return sizeof array.
Why are you checking for 'a', 'y' and '.' in the input?
strcpy(str2, Store[k])? second argument needs to be a string, Store[k] is a character !
There might be more issues, i have only checked that much as of now.
quite a complicated code for simple task.
But probably you are learning so it's ok for the time being.
~ swim ~
Thanks for helping me out. I'm checking for 'a', 'y' followed by a ' ' or '.' as I wish to remove those characters from the input string (eg : ayI ovelay odingcay. → I love coding.)
Ok, I get it, I'll try and fix that part of strcpy.
I realise I am making it overly complicated, I'm very new to C, barely a couple of weeks in, so I'm still trying to wrap my head around most of the things. I'll try to make the codes more precise and cleaner from now on.
Thanks again for your advice.