You are not logged in.
Is there a function from the standard c library to do that for me?
Offline
standard c or c++?
in c++:
string::iterator it=temp.end();
temp.erase(remove(temp.begin(),temp.end(),' '),it);
to remove whitespaces of a string.
In c i'd rather use strtok:
char *as,*df;
as = strtok(str, " ");
while ((df = strtok(NULL, " ") != NULL)
{
strcat (as,df)
memset (df, 0, strlen (df));
}
Lg,
STi
Ability is nothing without opportunity.
Offline
Nifty trick. Thanks for the advice
Offline
better to run a python instance and run string.trim()
RD&H
Dusty
Offline
but if i use python i won't be a 1337 H4XX0RZ
Offline
No, you'll be an efficient hacker...
Dusty
Offline
Actually I was going to try to learn some python...I don't know what happened...
Offline
Got bogged down in C! :-D
I don't understand when people who can program in one language say "I was going to learn Python". Python doesn't have to be learned. If you understand structured and/or object oriented programming, you know Python already; its just the natural syntax you would use.
I like Java.
Dusty
Offline
Yeah, thats right. I was going to learn c and python at the same time, but then i got so excited about c...well...
I can see what your saying about the python syntax...its very easy to read.
I like Java.
Dusty
I haven't seen you say something like that in a very long time.
Offline
better to run a python instance and run string.trim()
But trim won't removing it from inside the string... you want replace(' ','');
#include <boost/string_algo/trim.hpp>
std::string s = " i hate whitespace ";
boost::trim(s);
s = "~~~~~some other crap~~~~~";
boost::trim_if(s, std::equals<char>('~'));
Offline
Yeah, I'm a troll. :-D
Dusty
Offline
i haven't seen that trim thing dusty is talking about but replace() fix stuff like this,
>>> g = " arch linux "
>>> g = g.replace(" ", "")
>>> print g
archlinux
arch + gentoo + initng + python = enlisy
Offline
How embarrassing.
trim() is java syntax. Under python I was thinking of strip. It works as so:
>>> g = " arch linux "
>>> g.strip()
'arch linux'
Offline
=>" xersex2 is very cool ".tr(" ", "")
=>"xersex2isverycool"
Mr Green
Offline
whatlanguageisthatgreen?
arch + gentoo + initng + python = enlisy
Offline
knowing Mr. Green, its probably lua, but could theoretically be ruby...
Or he made it up. :-D
Dusty
Offline
i tried lua and it didn't work
does'nt ruby work in a terminal?
arch + gentoo + initng + python = enlisy
Offline
looks like ruby
Writing stories for a machine.
Offline
a little bird whispered in my ear that rubys terminal is called 'irb'
arch + gentoo + initng + python = enlisy
Offline
rofl ....
Mr Green
Offline