c++

Formatting Output

Hello fellow www-people! I need to output numbers in scientific notation such that there is always a "0" before the decimal point. e.g. For the number x = 134.87546, I need to produce the output 0.134875E03 NOT 1.348755E02 Does someone know how to do this? Thanks in Advance --Shiraz. ...

Is this ambiguous or is it perfectly fine?

Is this code ambiguous or is it perfectly fine (approved by standards/has consistent behavior for any compilers in existence)? struct SCustomData { int nCode; int nSum; int nIndex; SCustomData(int nCode, int nSum, int nIndex) : nCode(nCode) , nSum(nSum) , nIndex(nIndex) {} }; edit: yes, I am...

Big Endian and Little Endian for Files in C++

I am trying to write some processor independent code to write some files in big endian. I have a sample of code below and I can't understand why it doesn't work. All it is supposed to do is let byte store each byte of data one by one in big endian order. In my actual program I would then write the individual byte out to a file, so I get ...

C++ inheritance and function overriding

In C++, will a member function of a base class be overridden by its derived class function of the same name, even if its prototype (parameters' count, type and constness) is different? I guess this a silly question, since many websites says that the function prototype should be the same for that to happen; but why doesn't the below code...

I need a tree dump option, which doesn't exist any more in current gcc versions

Older versions of gcc (for example 4.0.2 or 4.1.2) had the option -df (see http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Debugging-Options.html#index-fdump_002drtl_002dcfg-357). I used this option to dump the files filename.c.134r.life2 and filename.c.126r.life1, because I want to extract some values out of these files (for example the reg...

Get enveloped data from MIME

Hello all I am receiving some encrypted data on a S/MIME message (not an e-mail, but SOAP request over SSL) and I need to get it out of the package. Does anyone know of any C/C++ interface to do it? I need something that just strips the SMIME headers and leaves me with the enveloped data, which I would then decrypt to get the MIME ...

Visual C++ Automatically Appending A or W to end of Function

In C++ I have defined a class that has this as a member static const std::basic_string<TCHAR> MyClass_; There is also a getter function for this value LPCTSTR CClass::GetMyClassName() { return MyClass_.c_str(); } When I create an instance of this class and then try and access it intellisense pops up but the name has been change...

How do I treat a pointer as a multi array?

Hi, I have this loop which gives seg. fault. s->c = malloc(width * height * sizeof(double)); if (s->c == NULL) { puts("malloc failed"); exit(1); } for (int n = 0; n < width; n++) { for (int m = 0; m < height; m++) { d = (&s->c)[m][n]; printf("d %f\n", d); printf("m %i\n", m); printf("n %i\n", n); ...

Downloading all files in directory using libcurl

Hi, I am new to the libcurl and found a way to download a single file from the ftp server. Now my requirement is to download all files in a directory and i guess it was not supported by libcurl. Kindly suggest on libcurl how to download all files in directory or is there any other library similar to libcurl? Thanks in advance. ...

Winsock accept event sometimes stops signaling (WSAEventSelect)

I have a problem with a piece of legacy c++/winsock code that is part of a multi-threaded socket server. The application creates a thread that handles connections from clients, of which there are typically a couple of hundred connected at any one time. It typically runs without a problem for several days (continuously), and then suddenly...

iconv encoding conversion problem

I am having trouble converting strings from utf8 to gb2312. My convert function is below void convert(const char *from_charset,const char *to_charset, char *inptr, char *outptr) { size_t inleft = strlen(inptr); size_t outleft = inleft; iconv_t cd; /* conversion descriptor */ if ((cd = iconv_open(to_charset, from_ch...

strange template namespace problem....

Hi, I've got a strange problem with templates and namespaces... I have the following code which compiles fine.. using namespace boost::multi_index; template < typename OT, typename KT, KT (OT::* KM)() const, typename KC, typename CMP > class OrderBook { public: OrderBook() {} ~OrderBook() {} typedef multi_index_container...

C++ Concatenate

What's the best way (best practice) to append one LPWSTR/LPTSTR to another, without having to convert to something else? ...

Is there a C/C++ project similar to portablepython?

I've searched the internet for this but couldn't find anything useable, I was just wondering if there exists a C/C++ project similar to portablepython? EDIT I guess the question becomes: is there a portable C/C++ compiler I can stick onto a usb key? ...

Using a Modifing a Radix Tree for implementing a URL matching algorithm

I am refactoring this algorithm completely. Basically I am re-implementing the ASP.NET MVC in C++ for another framework. I'm trying to implement a URL matching algorithm and I figured that radix tree would be the best choice for the keys searching because some url prefixes might be shared. Also searching may be very efficient considerin...

can someone help me translate this c++ code to c?

this is a magic square generator, but do not know C++, I have some difficulties to convert this code: #include <vector> #include <iostream> using namespace std; //There two series will be on even in case of magic square // One of even order will be for multiple of 4 void BuildDoublyEvenMagicSquare(vector<vector<int> > &mat, int Order); ...

C++ Streams compared to .NET Streams?

Is there any reason the stl still uses the streams that it does? It seems that .net streams are much easier to use and implement. I can understand them keeping them due to compatibility reasons but why haven't they added a new stream implementation more like .net? What are some pros and cons of the C++ streams compared to .NET streams? ...

C++ class scope

I'm coming to C++ from Objective C and have a problem... This works :- function1(char *filePath) { Box box(filePath); // construct/create a box using filePath // can use box in this function and destructor is called when function exits } However I need something like this, where function1 and function2 are called asynchrono...

When I kill a pThread in C++, do destructors of objects on stacks get called?

I'm writing a multi-threaded C++ program. I plan on killing threads. However, I am also using a ref-counted GC. I'm wondering if stack allocated objects get destructed when a thread gets killed. ...

C#/C++/CLI Exposing a method with a return type of list in my C++/CLI assembly to my C# project (Beginner Question)

I'm a begineer to C++/CLI, so bare with me. I have a C++/CLI project that wraps a native C++ application, which I use in my C# project. I added a few void methods in my C++/CLI class which expose correctly to my C# project. The intellisense shows fine in C# and I can interact with the methods. However, when I put a return type of a s...