If your code is huge then break it into functions
If you have to pass some parameters to the functions, passing them by pointers has an advantage that you can manipulate the value of the string inside the function
Does this answer your question ?If not phrase it differently. As of now its not making any sense at all
Whenever possible, try to avoid nested loop as they have a worst-case of O(n2) - Big O n square. In simple terms, it has bad processing time because your worst case for nested loop is n square iterations. When your n is sufficiently large, your logic will take a very long time to run.