Re: Safest way to convert char's to int's
From: Andrew Falanga (falandr_at_hp.com)
Date: 08/12/04
- Next message: Thomas Matthews: "Re: Currency converter"
- Previous message: Chris \( Val \): "Re: Which one of these books is best for beginners?"
- In reply to: Chris \( Val \): "Re: Safest way to convert char's to int's"
- Next in thread: Chris \( Val \): "Re: Safest way to convert char's to int's"
- Reply: Chris \( Val \): "Re: Safest way to convert char's to int's"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 12 Aug 2004 08:44:38 -0600
>
> # include <iostream>
> # include <ostream>
> # include <string>
> # include <cstdlib>
>
> int main()
> {
> static const char* Digits( "0123456789" );
> std::string Buffer( "1.3.6.1.5.1.11.3.2.1.4.25.0" );
>
> std::string::size_type Pos( 0 );
> std::string::size_type OldPos( 0 );
>
> while( ( Pos = Buffer.find_first_of( Digits, OldPos ) )
> != std::string::npos )
> {
> std::cout << std::strtoul(
> Buffer.substr( Pos, 1 ).c_str(), 0, 10 ) << " ";
>
> OldPos = Pos + 1;
> }
>
> return 0;
> }
>
> Cheers.
> Chris Val
>
>
I am actually doing this in C++. Please forgive the ignorance, but I
don't know what you're doing up there. Could you please provide an
explaination?
---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled. I do not wish my account at HP to
become a spam haven.
- Next message: Thomas Matthews: "Re: Currency converter"
- Previous message: Chris \( Val \): "Re: Which one of these books is best for beginners?"
- In reply to: Chris \( Val \): "Re: Safest way to convert char's to int's"
- Next in thread: Chris \( Val \): "Re: Safest way to convert char's to int's"
- Reply: Chris \( Val \): "Re: Safest way to convert char's to int's"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|