Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- const char* frase = "oi pessoal da vida !";
- char* dest = (char*) malloc (sizeof(frase)+1);
- int f=0,d=0;
- while(frase[f++] != '\0') {
- if(frase[f-1] != ' ')
- dest[d++] = frase[f-1];
- }
- print(dest);
- return 0;
- }
- //or
- //not by me
- #include <stdio.h>
- void remove_space(char *d, const char *s){
- for(;*s;++s){
- if(*s != ' ')
- *d++ = *s;
- }
- *d = *s;
- }
- int main(){//DEMO
- char secuencia[] = "1 2 3 4 5 6 7 8 9";
- char temp[sizeof(secuencia)];
- remove_space(temp, secuencia);
- puts(temp);//123456789
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement