Skip to content

Instantly share code, notes, and snippets.

@outlinepix
Created August 8, 2022 10:28
Show Gist options
  • Save outlinepix/bd2ea2dbb859653d5f90e6a5e9763c68 to your computer and use it in GitHub Desktop.
Save outlinepix/bd2ea2dbb859653d5f90e6a5e9763c68 to your computer and use it in GitHub Desktop.
slice() function to slice character from word and return new sliced word in C language.
void *slice(void *, int); /*prototype*/
void *slice(void __restricted *ptr, const int size)
{
char* newPtr = (char*)malloc(size);
memcpy(newPtr, ptr, size);
return newPtr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment