Ch1/LineWhitespaceCleanup.c
int remove_trailing_whitespace(char line[], int length) {
    int index = length - 1;
    while (index >= 0) {
        if (line[index] == ' ' || line[index] == '\n' || line[index] == '\t') {
            line[index] = '\0';
            index--;
        }
        else {
            return index + 1;
        }
    }
    return 0;
}
// This function modifies the original line array directly by replacing trailing whitespace with null terminators
// Returns the length of the string after whitespace removal or 0 if the line was blank
This function modifies the original line array directly by replacing trailing whitespace with null terminators
Returns the length of the string after whitespace removal or 0 if the line was blank
This function modifies the original line array directly by replacing trailing whitespace with null terminators Returns the length of the string after whitespace removal or 0 if the line was blank
int remove_trailing_whitespace(char line[], int length) {
    int index = length - 1;
    while (index >= 0) {
        if (line[index] == ' ' || line[index] == '\n' || line[index] == '\t') {
            line[index] = '\0';
            index--;
        }
        else {
            return index + 1;
        }
    }
    return 0;
}
int remove_trailing_whitespace ( char line [ ] , int length ) { int index = length - 1 ; while ( index >= 0 ) { if ( line [ index ] == ' ' || line [ index ] == ' \n ' || line [ index ] == ' \t ' ) { line [ index ] = ' \0 ' ; index -- ; } else { return index + 1 ; } } return 0 ; }
This function modifies the original line array directly by replacing trailing whitespace with null terminators
Returns the length of the string after whitespace removal or 0 if the line was blank
This function modifies the original line array directly by replacing trailing whitespace with null terminators Returns the length of the string after whitespace removal or 0 if the line was blank