Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- int no_space_strlen(const char *s) {
- int len, j;
- len = j = 0;
- while (s[len] != '\0') {
- if (s[len] == ' ')
- j++;
- len++;
- }
- return (len - j);
- }
- char *no_space(const char *str_in) {
- char *space_free;
- int i, j;
- i = j = 0;
- space_free = (char *)malloc(sizeof(char) * no_space_strlen(str_in) + 1);
- while(str_in[i] != '\0' && space_free != NULL) {
- if(str_in[i] != ' ') {
- space_free[j] = str_in[i];
- j++;
- }
- i++;
- }
- space_free[j] = '\0';
- return (space_free);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement