Archive

Archive for the ‘Functions List’ Category

atol()

July 26th, 2010 c# No comments

Prototype: long atol(const char *string);
Header File: cstdlib or (stdlib.h for C)
Explanation: This function accepts a string and converts it into a long. For example, if “1234″ is passed into the function, it will return 1234. It is similar to atoi, except that it can handle larger numbers (up to the maximum size of a long). If the string contains a decimal place, the number will be truncated. Eg, “104.21″ will be returned as 104.

.

//Example reads in a string, and converts it to a long
#include
#include

using namespace std;

int main()
{
char a_char[10];
cin>>a_char;
cout<<"As a long: "< }

Categories: Functions List, Resources Tags: