Re: Safest way to convert char's to int's

From: Andrew Falanga (falandr_at_hp.com)
Date: 08/12/04


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.



Relevant Pages

  • Re: C++ problem with a destructor
    ... > Sock(string s, int p) { ... memset(he, 0, sizeof(struct hostent)); ... I do not wish my account at HP to ... become a spam haven. ...
    (alt.comp.lang.learn.c-cpp)
  • [PATCH] Do not account for the address space used by hugetlbfs using VM_ACCOUNT V2 (Was Linus 2.6.29
    ... Do not account for the address space used by hugetlbfs using VM_ACCOUNT ... private mappings and special mappings. ... unsigned long address, int write_access); ...
    (Linux-Kernel)
  • RE: Verifying E-Mail Addresses
    ... could be a person's work email, their AO_Hell account, etc. ... ... such a resource, instead of how to secure it. ... mastery of a subject or superhuman command of the English language, ... correspondence with the sender upon realizing your own ignorance, ...
    (Security-Basics)
  • Re: Printing Issue
    ... something to do with account impersonation, ie using the "Run As" command ... > private int DeviceCapabilities(short capability, IntPtr pointerToBuffer, ... > pointerToBuffer, int defaultValue, string printerName) ... > // Initialize PRINTDLG ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: Bit array column for export
    ... Can you modify the stand alone system to expect an integer number equal to ... serviceId int not null primary key, ... insert into tableA values ... > the export that uses bit-array logic to relate services to the account. ...
    (microsoft.public.sqlserver.programming)