Last active
December 27, 2018 19:06
-
-
Save FFY00/7ff37f80ec4f8423cf4fcf6cdefc2197 to your computer and use it in GitHub Desktop.
Remove newline C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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