Reputation: 1447
I have a variable buf
stored as char *buf
this variable comes out to be an ID that looks something like /3B494538-9120-46E0-95D4-51A4CF5712A1
. I want to remove the first element of the char *buf
so that /3B494538-9120-46E0-95D4-51A4CF5712A1
becomes 3B494538-9120-46E0-95D4-51A4CF5712A1
. How do I do this?
Upvotes: 1
Views: 109
Reputation: 1469
You can create an array that reuses buf
's memory:
char *nonCopyBuf = buf + 1;
or allocate new memory storage:
char *copyBuf = malloc(strlen(buf));
memcpy(copyBuf, buf + 1, strlen(buf));
//...
free(copyBuf);
Upvotes: 4