Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Untitled
SUBMITTED BY:
Guest
DATE:
Nov. 25, 2014, 6:01 p.m.
FORMAT:
C++
SIZE:
852 Bytes
Raw
Download
Tweet
HITS:
1142
Go to comments
Report
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
void
smarty
(
char
*
str
)
{
char
*
word1
=
strtok
(
str
,
" "
);
char
*
newstr
=
(
char
*
)
malloc
(
strlen
(
word1
)
+
1
);
char
*
word2
=
strtok
(
NULL
,
" "
);
while
(
str
!=
NULL
)
{
if
(
strcmp
(
word1
,
word2
)
==
0
)
{
newstr
=
(
char
*
)
realloc
(
str
,
strlen
(
str
)
+
strlen
(
word1
)
+
1
);
strcat
(
newstr
,
" "
);
strcat
(
newstr
,
word1
);
}
else
{
newstr
=
(
char
*
)
realloc
(
str
,
sizeof
(
newstr
)
+
(
sizeof
(
word1
))
+
(
sizeof
(
word2
)));
strcat
(
newstr
,
" "
);
strcat
(
newstr
,
word1
);
strcat
(
newstr
,
" "
);
strcat
(
newstr
,
word2
);
}
word1
=
strtok
(
NULL
,
" "
);
word2
=
strtok
(
NULL
,
" "
);
str
+=
strlen
(
word1
)
+
strlen
(
word2
)
+
2
;
}
}
void
main
()
{
char
str
[]
=
"penis burger burger vurger penis"
;
smarty
(
str
);
getch
();
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus