homepage Welcome to WebmasterWorld Guest from 54.167.41.199
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
string to int
camilord




msg:3450704
 2:04 pm on Sep 14, 2007 (gmt 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.

sample...

=============

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]

 

wruppert




msg:3451442
 4:08 am on Sep 15, 2007 (gmt 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;
}


Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved