Skip to content

Commit

Permalink
final scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaansathaye committed Dec 5, 2022
1 parent 320026c commit 955ee82
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Final/string.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *remove_trailing(char *str){
size_t size = strlen(str);
while (size >= 0 && isspace(str[size-1])){
str[size-1] = '\0';
size--;
}
return str;
}

int main() {
char *str = malloc(100);
strcpy(str, "Hello World! ");
char *temp = remove_trailing(str);
printf("%s\n", temp);
return 0;
}

0 comments on commit 955ee82

Please sign in to comment.