Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- char *izbaci_viska_razmake(char *s) {
- char *pom = s;
- char *pom2;
- // Izbacivanje s pocetka rijeci
- if(*s == ' ') {
- char *pom1 = s;
- while(*pom1 == ' ') {
- pom1++;
- }
- pom2 = pom1;
- while(*pom2 != '\0') {
- *s = *pom2;
- s++;
- pom2++;
- }
- *s = '\0';
- }
- // Izbacivanje visestrukih razmaka
- s = pom;
- char *pom3, *pom4, *pom5;
- while(*s != '\0') {
- if(*s == ' ' && *(s + 1) == ' ') {
- pom3 = s;
- pom5 = s;
- while(*pom3 == ' ') {
- pom3++;
- }
- pom4 = pom3;
- pom5 = pom5 + 1;
- while(*pom4 != '\0') {
- *pom5= *pom4;
- pom5++;
- pom4++;
- }
- *pom5 = '\0';
- }
- s++;
- }
- // Izbacivanje razmaka na kraju
- s = pom;
- char *pom6;
- while(*s != '\0') {
- s++;
- }
- if(*(s-1) == ' ') {
- pom6 = s;
- pom6 -= 1;
- while(*pom6 == ' ') {
- pom6--;
- }
- *(pom6 + 1) = '\0';
- }
- return pom;
- }
- int main() {
- char s[] = " Volim OR ";
- printf("%s", izbaci_viska_razmake(s));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement