c++

why when writting more than once to socket, it blocks?

hi I am facing a problem with socket and I would be glad if you could help ... The problem is that when I send data more than once it blocks, e.g: //--- client --- //.. send(sock, buf_1, sizeof(buf_1), 0); for (x10){ //... send(sock, buf_2, sizeof(buf_2), 0); if (recv(sock, buf_2, sizeof(buf_2), 0)<0) printf("recv_2() fai...

[C++] std::getline does not work inside a for-loop

Hello there, I'm trying to collect user's input in a string variable that accepts whitespaces for a specified amount of time. Since the usual cin >> str doesn't accept whitespaces, so I'd go with std::getline from <string> Here is my code: #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace st...

C++ programmer needs n00b info on programming MySql from C/C++

I need to get up to speed really quickly on programatically creating an manipulating a MySql database from C or C++. The d/b might be on the same machine, or might be remote. is there a "definitive" book I can read (maybe O'Reilly?), or a great tutorial website? Thanks, ~mawg(); ...

Is Foo* f = new Foo good C++ code

Reading through an old C++ Journal I had, I noticed something. One of the articles asserted that Foo *f = new Foo(); was nearly unacceptable professional C++ code by and large, and an automatic memory management solution was appropriate. Is this so? edit: rephrased: is direct memory management unacceptable for new C++ code, in gener...

Glass Effect - Artistic Effect

I wish to give an effect to images, where the resultant image would appear as if we are looking at it through a textured glass (not plain/smooth)... Please help me in writing an algo to generate such an effect. Here's an example of the type of effect I'm looking for The first image is the original image and the second image is the outp...

Is it good practice to initialize array in C/C++?

I recently encountered a case where I need to compare two files (golden and expected) for verification of test results and even though the data written to both the files were same, the files does not match. On further investigation, I found that there is a structure which contains some integers and a char array of 64 bytes, and not all...

PostgreSQL : SQL timestamp to Unix timestamp using libpq

I know I can convert SQL timestamp to unix timestamp, using the following way. SELECT extract(epoch FROM now()); Now, I have a stored procedure function, which will directly return a table row to the caller. One of the row field is "timestamp" type. In my application, I am using libpq. I wish to use libpq functions (or any c/c++ func...

Show dialog/frame fullscreen on a second sceen sing QT/c++

I have an application with a secondary view that should be shown fullscreen on the other monitor (the one the main app is not on). Displaying the frame works quite well with frame.showFullScreen(); But, how can I tell it which screen it should be on? Is there a way to detect if a second screen is avauilable, as well? ...

Best way to start, stop and send parameters to separate Python script from C++ application ?

I try to explain the situation: I have a QT application written in C++ and QT. This QT application starts a separate console C++ application that runs in the background. These two communicate using perhaps sockets, don't know yet. Console C++ application needs to start and stop my gnuradio python script. Also it needs to send parameter...

QtWebkit as a desktop application GUI

Hi I was wondering if anyone knows about good tutorials or articles describing methods of creating an HTML GUI for an application using QTWebKit for a windows desktop application. I am mainly concerned about communicating messages, events and information between lets say a DLL(written in C++ for example) and the GUI (QtWebKit). need g...

Why does my code result in "cannot instantiate abstract class"?

This is the line where the error occurs: this->_tbfCmdHandler.reset(new Bar()); facade_impl.cpp(202): error C2259: 'FOO::Bar' : cannot instantiate abstract class due to following members: 'void Subscriber::update(T)' : is abstract with T=char & observer.h(66) : see declaration of ...

Java to c++ guides

Are there any good guides online to prime an advanced Java user for advanced C++ in a short period of time? ...

Convert CString to std::wstring

Can any one tell me how to convert CString to std::wstring ...

C++ design problem

I have a class hierarchy as such: Entity Stationary Tree Creature Bear Crow And I have a World and a Player. When the Player bumps into something it gets a call to handleCollision(Entity* entity) and then depending on what it is different things happen; if the player bumps into a tree noth...

Migration from MSXML to Xerces

I am planning to port my application from Windows to Linux, currently my application uses MSXML for XML parsing. I have decided to use Xerces XML parser to provide a cross platform solution. My code size is too big and I do not want to touch all the internal part of the code for this porting purpose as it might break some of the function...

access declaration can only be applied to a base class member

i'm using the observer pattern. I've a class that implements the publisher class: class foo : public Publisher<const RecoveryState &>, public Publisher<char &>, therin in try to bind the attach function: using Publisher<const RecoveryState &>::attach; using Publisher<const char &>::attach; the RecoveryState works, but at the...

C++: Constructor accepting only a string literal

Is it possible to create a constructor (or function signature, for that matter) that only accepts a string literal, but not an e.g. char const *? Is it possible to have two overloads that can distinguish between string literals and char const *? C++ 0x would kind-of allow this with a custom suffix - but I'm looking for an "earlier" sol...

File preview component (C++/MFC)

Is anyone aware of a good, general purpose file preview component for MFC/C++ desktop applications? Specifically, I'm looking for a component that I could embed in my application that would allow a broad range of file types (text files, multimedia, etc.) to be previewed without the need for original applications (such as MS Word, etc.) ...

TI DSP: interfacing C++ and assembly

I posted this Q to TI's 28xx DSP forum but haven't heard a response and figured maybe someone here might know. I know how to write functions in assembly so that they are C-callable; if the C-callable name is foo() then the assembly function is named _foo(). What if I want to use C++ and optimize a class method in assembly? How do I d...

How do I let a program D read a memory location within the memory allocated to a program A?

So I'd like to let read D read this memory location and do some work on it. Any thoughts? Is writing a debugger extension the only way - if so, any recommendations? I considered executing a memory dump to file (still don't know how, AFAIK I can only view memory in a window) and letting D work on the file, but is there a better way? ...