Ok, I'm a novice to average coder, but I'm mostly familiar with C++ functions, and for the life of me I can't find a way to break apart a string and simply remove (as in not replace it with a character - shift all the characters over, or at least make that character not display, whatever is easiest) a character (the first character) from a string.
The reason is rather silly, but I wanted it to be my first session with string manipulation, from there I'll branch out and get into more complex things. Oh, and this is for channel-stuff, so that when you type OOC *goes to take a shower... it removes the first character (the asterisk), and I also think it'd be nice to check and see if the last character is an asterisk, too, if so, then make it the terminate character.
It really depends on what you want to do with the string. If all you are going to do is read it once and not keep it around in memory, you can just do str+1 -- that will be the same string as str, except starting one character in.
Of course, that's not necessarily a safe pointer to keep, because the original string could change at any point, and it's unclear is the new string is still valid.
What Gohan proposed is a way to copy the entire string into a static buffer. It's still not a safe buffer to keep around, because future calls to the function will change the contents of the buffer -- therefore changing the string it returned.
If you really, really want unique strings that you can hold on to, you will have to allocate a block of memory and do basically what Gohan's function does, except that you use the malloc'ed memory instead of the static buffer.
Yes, strlen returns the exact length of the string. But these things are zero-indexed, so you're off by one.
str[strlen(str)] will get you the last character, meaning the trailing \0. What you really want is str[strlen(str) - 1], except that in that case you of course need to make sure the string is not empty.
If you don't care about what happens to the string, and just need to print it once, I would recommend not copying it but simply advancing the pointer by one.