Skip to content

Instantly share code, notes, and snippets.

@jshardy
Created February 26, 2019 09:30
Show Gist options
  • Save jshardy/9967872e766dc0c130bee8ca38f6f683 to your computer and use it in GitHub Desktop.
Save jshardy/9967872e766dc0c130bee8ca38f6f683 to your computer and use it in GitHub Desktop.
PadString
/**********************************************************************
* Function: padString(char *string, size_t size, fillchar)
* Purpose: padString for writing specific data file
* Precondition: pass string, total string size desired, and fillchar
* Postcondition: string is padded with fillchar
************************************************************************/
void padString(char *string, size_t size, char fillchar)
{
size_t i = 0;
while(*string != 0)
string++, i++;
if(i < size)
memset(string, fillchar, size - i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment