c++

Use _tcstoul to detect invalid string during unsigned long conversion - unable to treat -ve string as invalid value

I try to use _tcstoul for string to unsigned long conversion. However, it doesn't treat -ve string input as invalid input. Is there any workaround for this? Or I had missed out something? #include <cstdio> #include <tchar.h> int main() { { unsigned long iResult(0); TCHAR *pszStopString; iResult = _tcstoul(_...

How to Convert a 12-bit Image to 8-bit in C/C++?

All right, so I have been very frustrated trying to convert a 12-bit buffer to an 8-bit one. The image source is a 12-bit GrayScale (decompressed from JPEG2000) whose color range goes from 0-4095. Now I have to reduce that to 0-255. Common sense tells me that I should simply divide each pixel value like this. But when I try this, the ima...

In C/C++, is char* arrayName[][] a pointer to a pointer to a pointer OR a pointer to a pointer?

I understood multi-dimensional arrays as pointers to pointers, but perhaps I am wrong? For example, I though: char * var = char var[] char ** var = char* var[] or char var[][] char *** var = char var[][][] or char* var[][] or char** var[] Is this incorrect? I was confused because I saw a char*[][] cast as a char** in a simple...

Question about custom windows authentication package

I'm building a custom authentication subpackage for MSV1_0 for Windows 7. I've used the msvsubauth sample in from the Windows SDK and I have 2 questions regarding some problems I'm facing with that: When I'm trying just to make sure that the routine get's invoked and set the Auth0 property in the registry to my package and add a simple...

How to use for_each here correctly?

Hi, I am new to all the functional stuff in STL. I tried to do smething but it fails horribly no matter how I try it. Please comment: #include <iostream> #include <algorithm> using namespace std; class X { public: void Print(int x) { cout << x << endl; } void Do() { ...

Is this code valid C++ ?

Is the following code valid C++? const int var = 10; { int var[var]; // why doesn't this give any error ? } Note : The code compiles on my g++ compiler. ...

How to find the library name for clucene

hello, i need to use clucene in my c++ apps and i have installed i tried using with my eclipse i cant find the library specication with clucene how to add the library say in project Properties->GCC c++ linker is there is any way to find the library name ...

accurate running time of each line and total running time for the following function

Show the accurate running time of each line and total running time for the following function: int f1(int n, int A[ ], int B[ ]) {                           if ( (n>=5) || (n<0) )                         return 0;               for (int i=0; i<=n; ++i)                 {                     A[I] = 0;                     for (int  j=0;  ...

C++ template work-around

On my C++ project, I recently stumbled upon a little problem: Templates. I declared a class, Data in my header file (which is shared by each .cpp), and gave it a template function. I implemented it in data.cpp. I soon remembered how templates are compiled on the spot, when they are referred to, and this breaks the declaration/implementa...

what is wrong with my openmp parellel programming

hello, i have a queue of urls and i am passing to an function it crawls and gets the url each url in a queue should be in parellel and crawl is an class and start is my function it crawls the url and if i run the program the each urls is executed one by one not in parallel while(!q.empty()) { #pragma omp parallel for ...

accurate running time of each line and total running time

Show the accurate running time of each line and total running time for the following function: int f1(int n, int A[ ], int B[ ]) { if ( (n>=5) || (n<0) ) return 0; for (int i=0; i<=n; ++i) { A[I] = 0; for (int j=0; j<i; ++j) ...

Creating own implementation of Boost::Archive

I'm currently creating a concept which uses Boost::Serialization and which needs to implement its own Boost::Archive cause the data has to be serialized in a certain way. There is documentation about implementing custom archives in the documentation: http://www.boost.org/doc/libs/1_44_0/libs/serialization/doc/index.html But I'm curious...

How hide C++ source code from customer

Hello everyone, I wish to send some components to my customers. The reasons I want to deliver source code are: 1) My class is templatized. Customer might use any template argument, so I can't pre-compile and send .o file. 2) The customer might use different compiler versions for gcc than mine. So I want him to do compilation at his en...

Wrapping C++ class in Objective-C

I have a C++ library that doesn't use namespaces. I want to port it to Objective-C. The problem is the name collisions between the two. I want it to have the same name in Objective-C that is the name of the C++ object. But, I just can't figure out the best way to do this without it just becoming a mess. I am hoping for a solution to this...

I needn't use the QT's dlls and I want to use libs, when I run exe.How can I do this?

I needn't use the QT's dlls and I want to use libs, when I run exe.How can I do this? ...

How do I down-cast a c++ object from a python SWIG wrapper?

The problem: I've wrapped some c++ code in python using SWIG. On the python side, I want to take a wrapped c++ pointer and down-cast it to be a pointer to a subclass. I've added a new c++ function to the SWIG .i file that does this down-casting, but when I call it from python, I get a TypeError. Here are the details: I have two c++ cl...

How to convert from BSTR to DATE

COleVariant var(bstrString); var.ChangeType(VT_DATE); DATE date = var.date; not seems to be working. Any ideas will be appreciated. Thanks. ...

How to get a snapshot of network video stream with curl in c/c++ in windows?

And exact the media type then save the captured image with correct extension? ...

How do I compile a simple c++ program that uses boost::thread in cygwin?

I installed boost on cygwin, and tried to compile the following program: #include <iostream> #include <boost/thread/thread.hpp> using namespace std; void hello() { cout << "Hello cworld" << endl; } int main() { boost::thread t(hello); t.join(); } via $ g++ test.cpp -lboost_thread /usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../...

Is there any way to make for_each take references?

Hi, This cites for_each as follows: template<class InputIterator, class Function> Function for_each(InputIterator first, InputIterator last, Function f); I have a collection std::list<std::string>, and a function void Do(std::string) works fine when given to for_each along with the iterators. But if I supply a function like void ...