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)

5+ Year Member

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 Sep 15, 2007 (gmt 0)

10+ Year Member

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;


Featured Threads

Hot Threads This Week

Hot Threads This Month