Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

string to int

2:04 pm on Sep 14, 2007 (gmt 0)

Junior Member

5+ Year Member

joined:Apr 20, 2006
votes: 0

i don't know where to post.. but it seems C in linux is similar to perl.. :)

anyway, my question is..

how can i rid off the colon (:) so that i can convert into integer.



int main()
char tmp = ":212:";
int mutated = 0;

//mutated = (int)(tmp); //converting to int...
//operation goes here...


how can i remove the colons so that i can convert it into integers...

[edited by: coopster at 6:22 pm (utc) on Sep. 17, 2007]
[edit reason] Disable graphic smile faces [/edit]

4:08 am on Sept 15, 2007 (gmt 0)

Full Member

10+ Year Member

joined:July 23, 2003
votes: 0

Perl was invented to make this stuff easy. String manipulation in C is a pain. It has been a few years since I wrote any C, so I may have messed up the syntax a bit. I would have done something like this:

char* skip_colons (char* src, char* dest) {
char* s = src;
char* d = dest;

while (*s++) {
if (*s!= ':') {
*d++ = *s;
*d = '\0';

return dest;


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members