Home
menubar
rss_feed

Previous Reference C++ Reference <cstdlib> Next Reference




C++ Reference: strtoul()





strtoul()


Declaration

unsigned long strtoul(const char* kcpString,
                      char** cppEndPointer,
                      int iNumberBase);

Description

Converts a string of numerical characters to an unsigned long value. The argument "kcpString" is a pointer to the string, "cppEndPointer" is a pointer to the terminating character, and "iNumberBase" is the number base of the string that is being converted.

Example

#include <iostream>
#include <cstdlib>

int main() {
    using namespace std;

    // Convert string of binary digits to an unsigned long
    const int kiBinary = 2;
    char caString[] = "1001";
    unsigned long ulNumber = strtoul(caString, NULL, kiBinary);
    cout << caString << " converts to " << ulNumber << " in binary." << endl;
    return 0;
}


Output:








Previous Reference C++ Reference <cstdlib> Next Reference




Home | Reference | Play Games! | Blog | Forum | Site Map | Contact Us


shadow bottom image