Skip to content

Instantly share code, notes, and snippets.

@FFY00
Last active December 27, 2018 19:06
Show Gist options
  • Save FFY00/7ff37f80ec4f8423cf4fcf6cdefc2197 to your computer and use it in GitHub Desktop.
Save FFY00/7ff37f80ec4f8423cf4fcf6cdefc2197 to your computer and use it in GitHub Desktop.
Remove newline C
/**
* @brief Removes newline from string. String will end in the first newline.
*/
void remove_newline(char str[MAX_STRING])
{
int i;
for(i = 0; i < MAX_STRING; i++)
{
if(str[i] == '\n')
{
str[i] = '\0';
/* return; */ /* Not allowed :/ */
i = MAX_STRING; /* Alternative to break the loop */
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment