Skip to content

Commit 955ee82

Browse files
committed
final scratch
1 parent 320026c commit 955ee82

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Final/string.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <string.h>
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
#include <ctype.h>
5+
6+
char *remove_trailing(char *str){
7+
size_t size = strlen(str);
8+
while (size >= 0 && isspace(str[size-1])){
9+
str[size-1] = '\0';
10+
size--;
11+
}
12+
return str;
13+
}
14+
15+
int main() {
16+
char *str = malloc(100);
17+
strcpy(str, "Hello World! ");
18+
char *temp = remove_trailing(str);
19+
printf("%s\n", temp);
20+
return 0;
21+
}
22+

0 commit comments

Comments
 (0)