c++

the functionalities of two lines of code

When I was trying to learn an existing program, I could not understand what the following two lines of code try to do? for(i=0;0==(x&1);++i)x>>=1; if(0==(x-=y)) return y<<i; Any explanations would be appreciated. ...

Kill some processes by .exe file name

Hi, how can i kill some active windows processes by searching with their .exe filenames in C# or c++.net ...

Data Structures... so how do I understand them?

So I am a Computer Science student and in about a week or so... I will be retaking a Data Structures course, using C++ for applying the theory. Yes, I did say "retaking". I took the course last Fall and I feel like there is more that I need to learn. Being a student, I feel that I MUST know the basics because it will be much easier to un...

get chuncked data from http server in C++

hi, i want to connect to a http server(something like google.com) and get data from it with chuncked property and then merge chuncked data together. ...

C++ , is this goto statement warranted?

hello I have changed title slightly because I thought this is more appropriate question. Would you refactor it (seems like legitimate use of goto) ? If, how would you refactor the following code to remove go to statement? if (data.device) { try { ... } catch(const std::exception&) { goto done; } ... // more t...

std::swap returns 0xBAADF00D

Hi I'm trying to swap two std::list< dontcare* >::iterators under Visual 2005. Iter it1 = ... ,it2 = ...; // it1 and it2 are ok, not end() or such if(...){ std::swap(it1,it2); } The swap works, but when I leave the if() scope, it1 points to 0xbaadfood. It2 is ok though.I tried several variations, including swap_iter and a hand-ma...

PostMessage: Access Denied

The application shall receive messages from all processes of the system. Messages are sent using PostMessage call, which returns an error (5, access denied). The code works correctly on Windows XP SP2, but on Windows 7 application receive messages from only itself, which it should be supposed to get message from every application. Rea...

Solving the array sum problem using iterators and testing for equality only

While getting ready for interviews, I decided to code the classic "Find if there are two elements in an array that sum up to a given number" question using iterator logic, so that it can be generalized to other containers than vector. Here's my function so far // Search given container for two elements with given sum. // If two such e...

C++ Singleton Threading problem

I have a C++ singleton that runs as a separate thread. This singleton is derived from a base class provided by a library and it overrides the method onLogon(...). The onLogon method is synchronous, it wants to know right away if we accept the logon attempt. Problem is we need to pass the logon information via message to a security ser...

How to replace allocators of stl with actual source code

Hello, I need to replace allocators with their original source code. I am extracting exported methods from PE export table and facing strange lengthy allocators where STL containers were used in original source code . for example if source code was typedef std::list<std::basic_string<_TCHAR> > TokenList; EXPORTS_API const TokenL...

When Does Visual Studio 6 Catch Structured Exceptions?

This is mostly curiosity, but I've been reading about the history of Visual Studio catching SEH exceptions in a C++ try-catch construct. I keep running across the assertion that older version Visual Studio with the /GX flag enabled would "somtimes" catch structured Win32 exceptions in a C++ catch block. Under what circumstances will Vi...

Symbian C++ - synchronous Bluetooth discovery with timeout using RHostResolver

I am writing an application in Qt to be deployed on Symbian S60 platform. Unfortunately, it needs to have Bluetooth functionality - nothing really advanced, just simple RFCOMM client socket and device discovery. To be exact, the application is expected to work on two platforms - Windows PC and aforementioned S60. Of course, since Qt lac...

Qt - Real time drawing

Hi, I want to show a car's path in a window in real time, how to do that, and what classes I have to use. Is there anything like drawing area, in Qt. Any Help will be appreciated. ...

do...while vs while

Possible Duplicates: While vs. Do While When should I use do-while instead of while loops? I've been programming for a while now (2 years work + 4.5 years degree + 1 year pre-college) and I've never used a do-while loop short of being forced to in the Introduction to Programming course. I have a growing feeling that I'm doin...

c++ opengl: can i calculate normals in gpu? If so, how?

Hiya. I have an opengl application that loads a dxf and draws it on the screen, each time i need to calculate normals. is there a way to calculate normals in GPU instead of CPU ? if so how ? ...

Operator commutativity for inequality != in C++

Hi, I have a quick question about the following expression: int a_variable = 0; if(0!=a_variable) a_variable=1; what is the difference between "(0 != a_variable)" and "(a_variable != 0)" ? I dont have any errors for now but is this a wrong way to use it?? ...

C++ Conditional Operator

I once seen a -wired- operator in C++ which assigns value if greater than.. it was a combination of ?, < and = e.g. let x = value if value is greater than x I do not mean x=(x<value)x:value It was some sort of x<?=value But I can not remember it exactly, and can not find it online... Can some one remind me of it? Thanks, ...

C++ what is worse abstracting away or converting?

Hi, I am in doubt: Or I abstract away my string-type and implicitly use the local stringtype or I use something like ICU and convert to the local type when needed. Let me give you an example the following: enum StringKind { ICU_STRING, STD_STRING, MSCORLIB_STRING, NSSTRING, ... /* You get the picture */ }; template<class E...

How can I resolve this address of overloaded member function issue?

It's hackish, I know, but I recently needed to implement a stream class which would act mostly like a standard stream, but which would detect the std::endl manipulator and special-case it's behaviour. My first attempt at a particular method implementation was... mystream& mystream::operator<< (std::basic_ostream<char>& (*p) (std::basic_...

Dynamic linking a library - successful when executable is built, same setup fails when another .so is made

I am writing a numerical code, in which I would like to use a third-party-written shared library. I am working on an x86_64 k8 architecture, under CentOS. The desired target that I would like to build would be either a Python or a Matlab extension module, which are, from what I understand, gcc-built dynamically-linked shared libraries, w...