How would I remove the first three letters of a string with C?
相关问题
- Multiple sockets for clients to connect to
- how to split a list into a given number of sub-lis
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- Generate string from integer with arbitrary base i
Add 3 to the pointer:
will print "def"
An alternative design:
For example, if you have
the simplest way to remove the first 3 characters will be:
b will contain "456"
But in general case you should also make sure that string length not exceeded
In C, string is an array of characters in continuous locations. We can't either increase or decrease the size of the array. But make a new char array of size of original size minus 3 and copy characters into new array.
Well, learn about string copy (http://en.wikipedia.org/wiki/Strcpy), indexing into a string (http://pw1.netcom.com/~tjensen/ptr/pointers.htm) and try again. In pseudocode: