Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What standard C library function converts a string to a double?

  1. atoi

  2. atol

  3. strtod

  4. atof

The correct answer is: atof

The standard C library function that converts a string to a double is atof. This function stands for "ASCII to float" and it takes a string as an input and converts it to a double. The other options provided, such as atoi and atol, convert strings to integers and long integers respectively. The function strtod also converts a string to a double, but it allows for more flexibility in the syntax of the string input, unlike atof which strictly follows the conventional decimal notation. Therefore, the correct answer is D.