While the title of this seems easy i fear it might not be :\
I'm trying to have my program search through a string to find the character '-' when it finds it, it will look at the next character and based on what that is it will run a certain function.
i.e.
in the function i want it to replace the "-a" with a word chosen at random, here is where i run into an issue.
is there a way that i can have the word placed into the string and the rest of the characters in the string moved down accordingly?
so if my string was "hello -a world!" and i wanted to put something like "small" starting at the '-' the end result would be "hello small world" instead of "hello smallrld"
Thanks in advance for any advice :)
p.s. i apologize for the use of hello world... so overused.
I'm trying to have my program search through a string to find the character '-' when it finds it, it will look at the next character and based on what that is it will run a certain function.
i.e.
Code:
if(string[i+1] == 'a'){
functiona(int i);
}
is there a way that i can have the word placed into the string and the rest of the characters in the string moved down accordingly?
so if my string was "hello -a world!" and i wanted to put something like "small" starting at the '-' the end result would be "hello small world" instead of "hello smallrld"
Thanks in advance for any advice :)
p.s. i apologize for the use of hello world... so overused.
Comment