std::string num = "0.6"; double temp = ::atof(num.c_str());
Does it for me, it is a valid C++ syntax to convert a string to a double.
You can do it with the stringstream or boost::lexical_cast but those come with a performance penalty.
Ahaha you have a Qt project …
QString winOpacity("0.6"); double temp = winOpacity.toDouble();
If the input data is a
QByteArray::toDouble will be faster.
- Sleep for milliseconds
- C++ Cout & Cin & System “Ambiguous” [closed]
- Floating point exception( core dump
- Passing Arrays to Function in C++
- Return array in a function
- Regular cast vs. static_cast vs. dynamic_cast
- What is an unsigned char?
- check if a std::vector contains a certain object?
- What does “#include
- How to convert an instance of std::string to lower case
- Error: No viable overloaded =
- Random number between 1 to 10 using C++
- Expected initializer before namespace
- A proper way to create a matrix in c++
- No matching member function for call to ‘push_back’ error
- “X does not name a type” error in C++
- Difference between long double and double in C and C++ [duplicate]
- Why there is no pop_front method in C++ std::vector?
- How do I generate a random number between two variables that I have stored?
- How to print pthread_t
- make: g++: Command not found
- Deep copy vs Shallow Copy
- Pointer to incomplete class type is not allowed
- C++ error: “Array must be initialized with a brace enclosed initializer”
- Why am I getting string does not name a type Error?
- How to avoid the error: terminate called after throwing an instance of ‘std::logic_error’ what(): basic_string::_S_construct null not valid
- Error while overloading operator (must be a nonstatic member function)
- C++ Fatal Error LNK1120: 1 unresolved externals
- Vector of structs initialization
- C++ deprecated conversion from string constant to ‘char*’
- Converting a vector
- Checking cin input stream produces an integer
- Where do “pure virtual function call” crashes come from?
- How to convert vector to array
- “non-standard syntax; use ‘&’ to create a pointer to member” error in Visual Studio 2015
- libpng warning: iCCP: known incorrect sRGB profile
- C++: Expression must have a constant value when declaring array inside function
- What is the best open XML parser for C++?
- *** No rule to make target ‘class.cpp’, needed by `build/….x86/class.o` Stop. error in Ubuntu
- What’s the difference between opening a file with ios::binary or ios::out or both?
- Hash function for a string
- CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
- How to run valgrind with basic c example?
- initial value of reference to non-const must be an lvalue
- Typedef function pointer?
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- cannot declare variable ‘’ to be of abstract type ‘’
- Difference between ‘struct’ and ‘typedef struct’ in C++?
- Debug vs Release in CMake
- C++ Matrix Class
- access violation reading location c++
- C++ template constructor
- error: called object type ‘int’ is not a function or function pointer
- Hash function for a string
- Is there a replacement for unistd.h for Windows (Visual C)?
- How to call on a function found on another file?
- How to project a point onto a plane in 3D?
- Using C-string gives Warning: “Address of stack memory associated with local variable returned”
- generate random double numbers in c++
- Cygwin Make bash command not found
- C++ Compiler Error C2280 “attempting to reference a deleted function” in Visual Studio 2013 and 2015
- Why use pointers?
- Why I cannot cout a string?
- How do I return a char array from a function?
- c++ reading csv file
- Don’t understand static boolean behavior
- How to write std::string to file?
- Member declaration not found
- What is the difference between a .cpp file and a .h file?
- Stable Cotangent
- How to change string into QString?
- Including .cpp files
- Class template inheritance C++
- C++ error: undefined reference to ‘clock_gettime’ and ‘clock_settime’
- Converting String to Cstring in C++
- creating dynamic array of string c++
- How well is Unicode supported in C++11?
- Initializing default values in a struct
- Warning: comparison of distinct pointer types
- Two decimal places using printf( )
- error C2244 unable to match function definition to an existing declaration
- Initializing pointers in C++
- Static vs dynamic type checking in C++
- “No rule to make target ‘install'”… But Makefile exists
- How to determine the version of the C++ standard used by the compiler?
- Make / gcc cryptic error 2: how to have more information?
- REGSVR32: the module “xxxxx.dll” failed to load … dependent assembly could not be found
- Error: expression cannot be used as a function?
- Evaluate a string with a switch in C++ [duplicate]
- C++ JSON Serialization
- stack around the variable…was corrupted
- Creating a list to hold objects in C++
- What does “warning: not all control paths return a value” mean? (C++)
- Array of Linked Lists C++
- Is it still safe to delete nullptr in c++0x?
- Declaration is incompatible with type
- One or more multiply defined symbols found
- I’m getting the error “stoi is not a member of std” in myprogramminglab [duplicate]
- Template constructor in a class template – how to explicitly specify template argument for the 2nd parameter?
- C++ float array initialization