C + + Atol

Source: Internet
Author: User

Function name: Atol functions: Convert string to grow integer usage: Long atol (const char *nptr);Introduction Edit Related functions: Atof,atoi,strtod,strtol,strtoul header file: #include <stdlib.h> define function: Long atol (const char *nptr); function Description: Atol () The parameter nptr string is scanned, skipping the previous empty characters (meaning that the left space of the string is ignored), until a number or sign is encountered to start the conversion, and then the non-numeric or string ends (' \ ") ends the conversion and returns the result. Return value: Returns the number of long integers after the conversion. If the passed-in string is empty, or if the string contains a non-Arabic sequence, the function returns the default value of 0. Additional instructions: ATOL () with the use of Strtol (nptr, (char**) null,10);2 Procedure Example 1 #include <stdlib.h> #include <stdio.h> int main( void ) {      long l;      char *str =  "98765432" ;      l =  atol (str);  /* 原来为l = atol(str); */      printf ( "string = %s integer = %ld\n" , str, l);      return (0); }3 Procedure Example 2

/* Convert string A and string B to numbers and add */

#include<stdlib.h> main() {      char a[]=”1000000000”;      char b[]=” 234567890”;      long c;      c= atol (a)+ atol (b);      printf (“c=%d\n”,c); }Perform c=1234567890------------------------------------------------------------------------------------------------ -----------_variant_t vt_decimal ext. int

_variant_t Vtsumcount = _bstr_t ("0");
Vtsumcount.changetype (Vt_decimal);

Char csumvalue[16]={0};
strcpy (Csumvalue, (LPCSTR) _bstr_t (Vtsumcount));

int sumcount;

Sumcount = Atoi (Csumvalue);

C + + Atol

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.