How do I convert a string in C++ or C to an integer array?
How do I convert a string into an array of integers? Can I use sstream, because atoi doesn't work?! ...
How do I convert a string into an array of integers? Can I use sstream, because atoi doesn't work?! ...
In the current standard of C++ (C++03), there are too few specifications about text localization and that makes the c++ developer's life harder than usual when working with localized texts. (Certainly the C++0x standard will help here later.) Assuming the following scenario (which is from real PC-Mac game development cases): responsiv...
Consider the following code: #include <stdio.h> namespace Foo { template <typename T> void foo(T *, int) { puts("T"); } template <typename T> struct foo_fun { static void fun() { foo((T *)0, 0); }; }; } namespace Foo { void foo(int *, int) { puts("int"); } } using namespace Foo; int main() { foo_fun<int> fun; fu...
Whenever I include boost in my project I get a million of these warnings. Does anyone know how I can get rid of the warnings? ../depends\boost/config/abi_prefix.hpp(19) : warning C4103: 'depends\boost\config\abi_prefix.hpp' : alignment changed after including header, may be due to missing #pragma pack(pop) I know I can d...
While browsing the various option switches for my compiler (GNU C++ 3.2.3 is supported by my organization for my given hardware configuration), I ran across this: -glevel : Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3. I compile...
I have this enum: enum ButtonState { BUTTON_NORMAL = 0, BUTTON_PRESSED = 1, BUTTON_CLICKED = 2 }; const u8 NUM_BUTTON_STATES = 3; In my Button class I have member variables ButtonState state; and ButtonColors colors[NUM_BUTTON_STATES];. When drawing the button, I use colors[state] to get the colours for whatever state the...
I am trying to pass a reference to a two-dimensional array to a function in C++. I know the size of both dimensions at compile time. Here is what I have right now: const int board_width = 80; const int board_height = 80; void do_something(int[board_width][board_height]& array); //function prototype But this doesn't work. I get this e...
For some reason the following code fails. You can't simply erase a reverse_iterator by using its base() method. #include <set> #include <iostream> int main() { std::set<int> setOfInts; setOfInts.insert(1); setOfInts.insert(2); setOfInts.insert(3); std::set<int>::reverse_iterator rev_iter = setOfInts.rbegin(); ...
Is there a way to set a pragma disable warning for visual studio for an entire solution? ...
Do you have a good book recommendation for c++0x? ...
Has anybody produced a C++ wrapper for SQL that allows to interface to flat files or an active DB server or possable an in memory DB depending on run-time configuration. I have seen: SQLite mySQL I am sure there are others. Both of these are really C and though they provide the same functionality there is no common interface (that ...
I am writing a library in standard C++ which does the phonetic conversion. I have used std::string as of now. But in future I may have to change this to someother (std::wstring or something else). So I need to write my library in such a way that I can switch this easily. I have done the following so far to achieve this. Created a heade...
I am just starting with C++ and got some problems in understanding how the scope for private member variables in a class works. Please see the below code class Foo{ private: std::vector<int> container; public: // other methods }; int main(int argc, char* argv[]) { Foo* foo = new Foo; // other method call...
This problem is a continuation of a previous problem: http://stackoverflow.com/questions/402432/c-returning-and-inserting-a-2d-array-object and it is highly recommended to view the link to understand the following. I followed through Adam Rosenfield's answer and it solved the first two problems. However the last problem is not yet to ...
It's been a longtime since I've done any C++ (probably about 13 years, since I graduated college). I've developing in various others languages since then. My new gig uses a fair bit of C++. Any recommendations for getting bootstrapped? To clarify -- I don't need an "into to programming" book. E.g., what's a variable, flow control, e...
Is there any better alternative for doing string formatting in VC6, with syntax checking before substitution? ...
if (vector1.x > ((float*)&vector1)[j]) Is j simply just an index into the vector? e.g. is C++ able to retrieve these values using array notation even though vector isn't an array? If so I'm guessing it achieves this by referencing vector by its address? ...
Hello, Happy new year! My question is how to check if a microphone and a speaker are from the same sound card on Windows platform. If they are from different cards, then the logic to handling timing will be different. I'm using both DSound and WMME API. Thanks in advance. regards, Yun ...
Hi, is there any way how to set std::setw manipulator (or its function 'width') permanently? Look at this: #include <iostream> #include <iomanip> #include <algorithm> #include <iterator> int main( void ) { int array[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256 }; std::cout.fill( '0' ); std::cout.flags( std::ios::hex ); std::cout.wid...
How are objects stored in memory in C++? For a regular class such as class Object { public: int i1; int i2; char i3; int i4; private: }; Using a pointer of Object as an array can be used to access i1 as follows? ((Object*)&myObject)[0] === i1? Other questions on SO seem to suggest that casting a struct to ...