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++ MPL
- Write a statement that displays the number of characters in string s.arrow_forward3. Regular expression for all strings starts with 10 ab and ends with 001 bba is. a. 101*0*001 b. 10(10)*001 c. 10(1u 0)*001 d. 10001 e. None of the above f. All of the abovearrow_forwardCheck 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_forward
- 1. 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_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 VB program to enter any string then check the string if that string was in the uppercase change it to lowercase and the string lowercase change to uppercase, use any variable you want...Use 2008 versionarrow_forward
- Write a statement that changes the first character in string s to 'P'.arrow_forwardIN C++ Write a program to input a string of even length and add the string "-MID-" at the middle of the input string and display the obtained string in the output.arrow_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 program that prompts the user to enter two strings and displays the largest common prefix of the two strings.arrow_forwardIn your reading you'll find pseudocode for finding one C-string inside another. Use that code to count the number of times that s2 appears inside the C-string s1. cstrings.cpp /** Count the number of times that s2 appears in sl. @param sl the string to search through. @param s2 the substring to search for. @return the number of times s2 appears in sl. 4 6 */ 7 int countCopies(const char* s1, const char* s2) 8 { 9 int count{0}; 10 11 12 13 return count; 14 } CodeCheck Resetarrow_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