vector <unsigned char> vs string for binary data
Which is a better c++ container for holding and accessing binary data? std::vector<unsigned char> or std::string Is one more efficient than the other? Is one a more 'correct' usage? ...
Which is a better c++ container for holding and accessing binary data? std::vector<unsigned char> or std::string Is one more efficient than the other? Is one a more 'correct' usage? ...
I need to call a DLL function from Access using VBA. The prototype for the DLL function is int __stdcall myFunction(const char* data, int rows, int cols, int sl, int fullsize, double aspect_ratio, double y, void** ppResult); The one I declared in Access: Private Declare Function DllImport_myFunction _ Lib...
How can I predict the size of a vector? #include <vector> #include <iostream> using namespace std; int main() { cout << sizeof(vector<char[8]>) << endl; cout << sizeof(vector<char[16]>) << endl; return 0; } [starlon@localhost LCDControl]$ ./test 12 12 ...
I am reading STL source code right now. Though I understand the meat in what I am reading in stl_list.h, I want to fully understand the following snippet (mainly related to the template syntax, I think). template class _List_base { ... typedef typename _Alloc::template rebind<_List_node<_Tp> >::other _Node_Alloc_type; //(1). ......
Hi i just started learning C++ couple of weeks ago. So now I have this school assignment problem that asks me to implement a linked-list without using "new" or anything to do with dynamically allocating memory (and cannot use any ADT from STL). The prof says that everything can be done on the stack, but how? I have been working on this s...
How to download webpage into string without saving this page to disk in C++? URLDownloadToFile MSDN function only saving page into disk. ...
I'm trying to call popen() using mingw like this: #define RUN_COMMAND "\"C:\\Program Files\\CA\\BrightStor ARCserve Backup\\ca_qmgr.exe\" \"-list\"" int main() { outputPointer = popen(RUN_COMMAND, "r"); ... } But I can't get it working. I think it's a quoting nightmare ... ...
This seems to be a common error, but most people online choose to just ignore the warning and move on. I do not wish to ignore the warning. Basically, when using __declspec(dllexport) to convert a project to use dlls, the compiler has trouble dealing with templates and stl objects. An explanation of the problem, and suggested solution...
I'm looking for an easy way to build an array of strings at compile time. For a test, I put together a class named Strings that has the following members: Strings(); Strings(const Strings& that); Strings(const char* s1); Strings& operator=(const char* s1); Strings& operator,(const char* s2); Using this, I can successfully compile co...
Is it Possible to limit the functionality of class to certain objects only (in C++). What that would mean is, suppose there are 10 methods in a class and this class has 10 objects. Is it possible to have object1 & object2 access only 3 functions. Object3, object4,object5, object6 access 6 functions. and rest of the objects access all fun...
I'm trying to to the most basic of things .... write a file in C++, but the file is not being written. I don't get any errors either. Maybe I'm missing something obvious ... or what? I thought there was something wrong with my code, but I also tried a sample I found on the net and still no file is created. This is the code: ofstream...
I generally prefer constness, but recently came across a conundrum with const iterators that shakes my const attitude annoys me about them: MyList::const_iterator find( const MyList & list, int identifier ) { // do some stuff to find identifier return retConstItor; // has to be const_iterator because list is const } The idea t...
I have a out-of-process COM server with an ATL Simple Object which creates another thread. The new thread will need to make calls to ATL Simple object. Since ATL Simple Object and new thread are created different apartments, ATL Simple Object needs to be marshalled in the new thread, otherwise error 0x8001010e will be generated. How do...
Hi there, this is for an assignment so I will be deliberately general. My question is related to implementation decisions I already made--maybe they weren't good ones. I have a list of pointers to structs, e.g. list<MyStruct*> bob; At one point I've needed to sort these pointers by one of the data members of their targets and I was able...
ok wtf this is what moc tells me when i try to moc one of my header files. im doing this through Qt 4.5.3 command prompt and it says this: C:\Documents and Settings\The Fuzz\Desktop\GUI2>moc App_interface.h /**************************************************************************** ** Meta object code from reading C++ file 'App_in...
i have to run the following commands from Qt command prompt: 'qmake -project' then 'make' and this gives me the debug folder with the Moc file. this is strangely the only way my PC will generate the moc_.cpp file. So how can i automate the task of these commands so i dont have to use these commands again? ...
I'm confused why the following C++ code can compile. Why does a call to delete the method of 0 not produce any error?! volatile *arr = NULL; // or if i use 0, it's the same thing delete arr; I did try to run it, and it did not give me any error at all... ...
This is a homework question I am sorry but I am lost. What happens is the following I am asked to do a tiling of hexagons. Like the grid map in many Risk games and Wild Arms XF. I understand the current transformation is the matrix that translates the points I give to OpenGL to screen coordinates and if you apply a transformation it move...
I have a boost pre-processor sequence defined as #define MY_SEQ ((a) (b1) (b2))\ ((b) (b3) (b4) (b1)) I want to generate two enums from this as, enum alist{a,b}; and enum blist{b1,b2,b3,b4}; The code below does not remove the duplicates from blist (LIST2 macro). Is it possible to remove the duplicates from the pre-processor list...
I am writing a small C++ program for fun and for extending my C++ skill. Since its scope is relatively small, I also planning to try out cross-platform development by making this program support both Windows and Linux. I reckon my C++ proficiency is sitting somewhere between casual and intermediate level: OO, a bit of templates and desi...