Get substring from a string?

I need to write a simple function that gets a three character string segment from the parent string.
char string[] = "Hello, my name is...";
I need to get something like "ame" out of the string above.
How do I do this?
Last edited on
You need to know which characters you want. The fastest way is:
1
2
3
4
5
char str[] = "Hello, my name is...";
char Derivated[4] = {0}; // 3 chars + terminator
Derivated[0] = str[12];
Derivated[1] = str[13];
Derivated[2] = str[14];
Thanks but how do i output the result. if it cout << Derivated or something else.
Yeah, cout << Derivated or cout >> Derivated i just don't know which one but i'm sure it will work.
Topic archived. No new replies allowed.