c++

Corrupted Binary Files after Transfer libcurl

I am transferring a binary file (.exe) with FTP using libcurl, and saving it to a local file. The problem is that after the file is transferred, it is altered and is no longer a valid Win32 application, and doesn't run. Here's how I'm doing it: CURL *curl; curl = curl_easy_init(); FILE* f = fopen("C:\\blah.exe", "w"); if(curl) { ...

references in c++ problem

Hi, I heard references in c++ can be intitalized only once but this is giving me 1 is my output and not returning any error! struct f { f(int& g) : h(g) { h = 1; } ~f() { h = 2; } int& h; }; int i() { int j = 3; f k(j); return j; } ...

boost spirit v2 compile error - trying to use symbols for something slightly harder and missing an important point somewhere

Hi, I have tried various approaches to fixing this issue with maps and casts, splitting the parse into different sub-pieces, using std::vector directly and trying _r1 etc. but I seem to have failed to grasp something fundamental about the use of attributes. I want to parse a line such as: DEFMACRO macroname param1 param2 param3 ... pa...

Transfer the audio stream of Skype

I am trying to transfer the sound stream of Skype to another application. I have already read in some forums that the Virtual Audio Cable can be used to do this. But, can this be done using the Skype4Com dll? I am looking for a sample C++ implementation of voicestream redirection using Skype4Com dll. ...

C++ Templated Functor (based on Modern C++ Design) compile error

Based on chapter 5 (Generalized Functors) from the book "Modern C++ Design," I'm trying to write a Functor template. Before asking me "why don't I just use Boost's bind or Loki straight up?" the simple answer is "because I want to learn." That being said, I have followed the book, and also used the example code as a reference, but I ke...

How to convert a sorted std::list of std::pair to a std::map

Hello! I have got a std::list< std::pair<std::string,double> >, which I know is sorted according to the std::string element. Since I would like to do a lot of std::find_if based on the std::string element, I believe a std::map<string,double,MyOwnBinaryPredicate> with lower_bound and upper_bound would be more adequate. The fact is tha...

Declaring and defining a function object inside a class member function

Hello to everyone, I wonder if and how it is possible to define a function object inside a classes member function to use it directly with, for example, the std::transform function. I know the example is a bit stupid, it's just to show the problem I'm confronted with. File "example.h" class Example { public: //.. constructor and...

Initializing std::tuple from initializer list

Hi, I'm wondering whether the tuple can be initialized by initializer list (to be more precise - by initializer_list of initializer_lists)? Considering the tuple definition: typedef std::tuple< std::array<short, 3>, std::array<float, 2>, std::array<unsigned char, 4>, std::arra...

How to add boost to my project?

I work on a cross-platform (Windows, Linux, Solaris) project. I want to use Boost's shared_ptr in this project. How can I install it, and redistribute it with the project to the customers? I don't have root permissions on Linux/Solaris, so I probably have to add Boost' sources to my sources, and build it together. Also, our version of...

When does a process get SIGABRT (signal 6)?

What are the scenarios where a process gets a SIGABRT in C++? Does this signal always come from within the process or can this signal be sent from one process to another? Is there a way to identify which process is sending this signal? ...

Code polisher / reformater for C, C++ or Fortran

Hello, suppose you have got a bunch of files written in C, C++ or Fortran, by different authors with different opinions on formating, how to comment (...) and so on. I think many people know situations like these. Are there any free tools for ends like: uniform format of code (indent etc.) create standard comment bodies rename variab...

What std::move() is?

What it is? What it does? When it should be used? Good links are appreciated. ...

write a C++ code to get the hostname

I want to write a C++ Code to get the full information on all the host name, and ip address and sub net mask of computer that has been added to the domain control. ...

How to generate import libray (libsample.a) from dynamic library (libsample.so) in Linux

After create dynamic library on Linux but I want to generate symbol link import library (.a) from dynamic library .so. What steps I do? ...

C++ - Sort multidimensional vector by its contained object property

Hi guys, I've got a bidimensional array of objects (a 2D vector containing GridCell instances) as in here: typedef vector<GridCell> CellArray; typedef vector<CellArray> TwoDCellArray; TwoDCellArray CellArr2D; I am currently drawing all the cells like this: for (int i = 0; i < rows; i++){ for (int j = 0; j < cols; j++){ C...

generate unique 5 digit number

i was told to write program which generate unique 5 digit number ( for example 12345 is unique and 11234 not) i have write following code #include <iostream> #include <stdlib.h> #include <map> using namespace std; using std::rand; const int k=99999-10234; bool unique(int t){ map<int,int>my; map<int,int>::iterator it; ...

Is there a pocket reference book for winapi?

I'm told that Programming Windows (Charles Petzold) is the most recommended full text for using C++ in the Windows API, but is there an O'Reilly-like pocket reference equivalent? ...

How to Check if a website contains Flash.

I've created a web browser using mfc and i'm using IHhmlReader to read the contents of html when the user enters a url in the browser and page is completely loaded.Now i want to check if the webpage has any flash in it. Any Helps would be highly appreciated. Thank You. ...

How to convert a string to complex<float> in C++?

How do I easily convert a string containing two floats separated by a comma into a complex? For instance: string s = "123,5.3";//input complex<float> c(123,5.3);//output/what I need Is there an simpler/faster way than to split the string, read the two values and return thecomplex<float>? ...

Add automation support to MFC DLL

Is there a way to add automation to an existing MFC dll? I know I can create a new project and select Automation during the wizard, but I already have a dll with ATL support which exposes a number of COM objects so I'd rather update that than have to recreated it. ...