I am posting this for a suggestion.
I want to know which is the optimized way for writing a C code for the below problem.
question is to ouptut the below string
"Post New Thread "
to
"Thread New Post"
I have 2 methods.
1. Read the each character in the input string and store it in stack(using recursion) and form a string during exiting the function (till a space is found) and print it in reverse.
2. Read each string and push to stack( using strstr() function, after getting the pointer to a 'space' in the string , store each word to stack(may be using recursion) and then print while exiting the recursive function)
Which one is more optimized? In terms of performance, suppose i have a big stack area... Or is there any other better method.( I dont need the code, i need the logic only...)
I am basically confused in a way that , is it better to use functions like strstr() when we write programs in the performance point of view. I dont know the internal implementation of these string functions..( Are these functions non standard? Some times i never see these functions inside string.h when googling..)