Created
March 17, 2015 10:46
-
-
Save tomcha/ed3856a0bfa6e84f8e13 to your computer and use it in GitHub Desktop.
1-18
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
| #include <stdio.h> | |
| #define MAXCHAR 100 | |
| void delblank(char line[], char newline[]); | |
| void cleararray(char array[]); | |
| int main(){ | |
| int c; | |
| int i; | |
| char line[MAXCHAR]; | |
| char newline[MAXCHAR]; | |
| while((c = getchar()) != EOF){ | |
| line[i] = c; | |
| if(c == '\n'){ | |
| delblank(line, newline); | |
| printf("%s\n", newline); | |
| i = 0; | |
| cleararray(line); | |
| cleararray(newline); | |
| }else{ | |
| i++; | |
| } | |
| } | |
| } | |
| void delblank(char line[], char newline[]){ | |
| int i, j; | |
| j = 0; | |
| for(i = 0; line[i] != '\n'; i++){ | |
| if(line[i] == ' ' || line[i] == '\t'){ | |
| i++; | |
| }else{ | |
| newline[j] = line[i]; | |
| j++; | |
| } | |
| } | |
| } | |
| void cleararray(char array[]){ | |
| int i; | |
| for(i = 0; i < MAXCHAR; i++){ | |
| array[i] = '\0'; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment