Why do people use some thing like char*&buf?
I am reading a post on Stack Overflow and I saw this function: advance_buf( const char*& buf, const char* removed_chars, int size ); What does char*& buf mean here and why do people use it? ...
I am reading a post on Stack Overflow and I saw this function: advance_buf( const char*& buf, const char* removed_chars, int size ); What does char*& buf mean here and why do people use it? ...
i know how to Start process with argument but im trying to create a program that uses this arguments. for example IE8 uses Process::Start( "IExplore.exe","google.com"); as a argument to open new window with url google.com. i want my program to use the argument are send it but i don't know how to get the the argument. like Process::Start(...
I'm using the following code in some cases: #define array_key_exists(find_key, arr) (arr.find(find_key) != arr.end()) But i also use simply this method: if(SomeMap["something"]){ // key exists } I am using String to int map. Are they both as fast...? Or is there a possibility for errors with the second case, assuming i am not ...
I have a program which runs a bunch of tasks as root at launch. After that it needs to drop to a different user. How can that be done? And just wondering, is it possible to reacquire root without relaunching the program? ...
I have a homework program that I need a little help on. I need to compare an array containing the answer key of a test to an array containing the student answers. The problem I am running into is that I need to take the blank answers into account. I cannot seem to come up with code that will compare the arrays, then display the score. Th...
Following an example in Accelerated C++, I created a custom STL container, which is a simplified version of std::vector, called Vec. Everything worked fine, until, emboldened by success, I tried to add a Vec::clear() that will clear the vector. Here's the latest class definition (only the relevant parts to this question): template <cl...
C++ Boost has Bimap container that is a bidirectional map: http://www.boost.org/doc/libs/1_43_0/libs/bimap/doc/html/index.html Does anyone know the performance of Boost::bimap? I mean what's the time complexity of accessing an element in the map? Is it as quick as unordered_map access (which is O(1))? Thanks! ...
Hi! I have some code that is going to be run thousands of times, and was wondering what was faster. array is a 30 value short array which always holds 0, 1 or 2. result = (array[29] * 68630377364883.0) + (array[28] * 22876792454961.0) + (array[27] * 7625597484987.0) + (array[26] * 2541865828329.0) + (array[25...
I'm trying to write a .bmp in C++ but unsigned char can't hold a value high enough for my needs and other data types add padding because of specific byte alignment that makes a mess of things. So is there an alternative data type that can hold a higher value that won't add padding (or a way to make unsigned char hold a higher value)? ...
I'm trying to write a function to "stringify" parameters for logging purpose. For example, I'd like to write something like this: vector<string> queries; set<uint_8> filters; LOG(INFO) << stringify<vector, string>(queries); LOG(INFO) << stringify<set, uint_8>(filters); Here is the function template I wrote: template <typename contai...
I know I can use MoveWindow to move it but I only want to move the button on the x axis. Thanks. ...
Hey, For some strange reason my depth buffer is not working, i.e. the triangles drawn later always overlap, regardless of their position. I have these presenter parameters D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.hDeviceWindow = mWindow; d3...
Take a variable length struct (if this were a real program, an int array would be better): #include <vector> struct list_of_numbers(){ int length; int *numbers; //length elements. }; typedef std::vector<list_of_numbers> list_nums; //just a writing shortcut (...) And build a vector out of it: list_nums lst(10); //make 10 lists. l...
I'd like to reduce some visual noise in the code and hide shared_ptr behind a typedef like this: typedef boost::shared_ptr<SomeLongClass> SomeLongClassPtr; So this: void foo(const boost::shared_ptr<SomeLongClass>& a, boost::shared_ptr<SomeLongClass>& b); becomes this: void foo(const SomeLongClassPtr& a, SomeLongClassPtr& ...
I have a stream of bytes that is being read in from a socket (little endian). Can someone tell me why only the last one of the methods below gives the correct answer? I suspect it's to do with the carry bit but not sure. I've always found that when printing binary data in hex form. e.g. printf("%02X", data); it sometimes prints ou...
Hi! I want to load collada with libxml2. I get the COLLOADA node, okay, then I try to get the children tag - FAIL, the children tag name is "text". Why? How can i get the child of COLLADA node? xmlNode* geometries = xmlDocGetRootElement(doc)->children; //at THIS point the geometries->name == "text" WHY? //IS not it supposed to be "as...
When I set additional compiler options for a project in Visual Studio 2008, they propagate to all files. If I then set additional options for a specific file, they are added to the project's command line and additional options. How can I compile an individual file without the project-wide options? ...
Hello guys, when I use recv from windows sockets does using recv can lead to denial of service attack ? If it waits for data forever? So what is the best way for solving this (alarms ?) Thanks & Regards, Mousey. ...
I'm using process::start(PATH); to open up the process. The problem is, sometimes it finds the file and sometimes it doesn't. For example, this works: process::start("C:\text.exe"); But this doesn't work: process::start("C:\New Folder\text.exe"); Any idea what the difference is? ...
I am looking to control some electronic servo's using the headphone port as a the control signal. I need to be able to generate a pulse width modulation signal and change the width of the pulse on the fly rapidly. I would prefer to do this in C# but can c++ is also an option. Any idea's how to go about doing this? ...