Concept explainers
“atol” function:
In C++, the predefined function “atol” is used to convert a string value into a long integer value; it passes a string literal or character array as an argument and it converts the received value into a long integer value; it takes only one parameter as an argument.
- If the argument value contains nonconvertible contents combined with the integer value then the values will be ignored while converting.
- In same way, the function will return “0” when the values can’t be able to convert into double data type.
Syntax:
Syntax for “atol” function is as follows:
long int atol (const char* n);
In the above statement,
- “long int” represents the return type of the function.
- “atol” represents the name of the function.
- “const char*” represents the data type of the passing argument.
- “n” is a string variable which is required to be converted.
Example:
The example for the “atol” function is as follows:
//change the string literal to a long type value
long n = atol ("123456 hello");
In the above line, the string literal “123456 hello” is passed as an argument to “atol” and it returns the converted value that is “123456”; here the “atol” function ignores the whitespace and the nonconvertible value “hello”.
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
Starting Out with C++: Early Objects (9th Edition)
- Write a statement that will convert the Base 3 string 21201 to a numeric integerand store the result in the variable numarrow_forwardWrite a statement that displays the number of characters in string s.arrow_forwardIn an output statement, the newline character may be a part of the string. (Mark the statements as true or false.)arrow_forward
- Check a character is present in string or not if yes then how many times else print 0 and you have to take string and character from user.arrow_forwardAn uppercase character is a character whose ASCII value is between 65(A) and 90(Z). Write a C++ program that prompts the user to enter a string from the keyboard and will count the number of uppercase characters and replace each uppercase character by the correspoding lowercase characterarrow_forwardWrite a code snippet that can count the occurrence of each character in the string. input string:Character Output: c=2 h=1 a=2 r=2 t=1 r=1arrow_forward
- The isupper function turns all uppercase letters in a string. Is it true or false?arrow_forward1. The following strings are accepted by the following DFA: a,6 a start 9 94 a. aaabb AND abab b. bbbaa AND aabba c. abb AND aaab d. E AND aaab e. None of the above f. All of the abovearrow_forwardWhat can be used to find the end of a c-string? null terminating character null empty string nullptrarrow_forward
- A C++ program to remove all characters in a string except alphabets. Use string = "Al769pha8be990ts"arrow_forwardWrite a statement that changes the first character in string s to 'P'.arrow_forwardWrite a program that prompts the user to enter two strings and displays the largest common prefix of the two strings.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education