- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I convert string to double in C/C++?
Here is an example to convert a string to double.
Example
#include <iostream> using namespace std; int main() { char s[20] = "18.2894 is a number"; char *p; double result; result = strtod(s, &p); cout<<"The number after conversion of string : "<<result; return(0); }
Output
The number after conversion of string : 18.289400
In the above program, a char type array s[20] is declared which is initialized with a alphanumeric characters. The function strtod() is used to convert that string into a double number.
char s[20] = "18.2894 is a number"; char *p; double result; result = strtod(s, &p);
- Related Articles
- How do I convert a double into a string in C++?
- How to Convert Double to String to Double in Java?
- Convert String to Double in Java
- Convert double to string in Java
- How can I convert Python tuple to C array?
- How can I convert a string to boolean in JavaScript?
- How can I convert bytes to a Python string?
- How can I convert a Python tuple to string?
- How to convert a double value to String in Java?
- Convert string (varchar) to double in MySQL
- Convert double value to string in Java
- Java methods to convert Double to String
- Java Program to convert String to Double
- How to convert a Double array to a String array in java?
- String format for Double in C#

Advertisements