I'm writing a client application to communicate with a server program via UDP. The client periodically makes requests for data and needs to use the most recent server response. The request message has a 16-bit unsigned counter field that is echoed by the server so I can pair requests with server responses.
Since it's UDP, I have to ha...
Hi all,
I am just trying to count the number of white spaces to the LEFT of a line from a text file.
I have been using
count( line.begin(), line.end(), ' ' );
but obviously that includes ALL white spaces to the left, in between words and to the right.
So basically what I'm wanting it to do is once it hits a non-space character stop i...
Hello all,
I am using standard template libraries along with boost. I want to debug code using cgdb. But I just want to debug my code while doing next and step in cgdb, like right now it enters the code in other libraries whereas I want it should just return or step into the code which I have coded and wrote down.
Is there any way to m...
Hello,
I'm currently using libxmlsec into my C++ software and I try to load a RSA private key from memory. To do this, I searched trough the API and found this function.
It takes binary data, a size, a format string and several PEM-callback related parameters.
When I call the function, it just stucks, uses 100% of the CPU time and nev...
Hi,
I'm developing for a platform without a math library, so I need to build my own tools. My current way of getting the fraction is to convert the float to fixed point (multiply with (float)0xFFFF, cast to int), get only the lower part (mask with 0xFFFF) and convert it back to a float again.
However, the imprecision is killing me. I'm...
It seems like I had to inline quite a bit of code here. I'm wondering if it's bad design practice to leave this entirely in a header file like this:
#include <list>
#include <string>
#include <boost/noncopyable.hpp>
#include <boost/make_shared.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <Windows.h>
#include "../Exception...
Does anyone know of any really good C++ Libraries for implementing a web services api over top of existing legacy code?
I've got two portions that are in need of it:
An old-school client/server api (No, not web based, that's the problem)
An old cgi application that it integrates with the client and server.
Let me know if you've ha...
Possible Duplicate:
Knight movement how to output all possible moves.
hi tried the following code and is still not working. it is having problem on backtracking. it just fills the squares of a board with numbers but not in expected order. The code is as follows :
#include <iostream>
#include <iomanip>
using namespace std...
Hi All
Visual studio allow you to create "inlined" classes (if I am not mistaken with the name).
So class header and implementation all in one file.
H. file contain definitions and declarations of the class and functions, there is no .cpp file at all.
So I was wondering if there is any penalty for doing it that way? any disadvantages...
I'm writing an algorithm that iterates over a list of points, calculates the distance between them and inserts additional points if the distance is too great. However I seem to be lacking the proper familiarity with STL to come up with an elegant solution. I'm hoping that I can learn something, so I'll just show you my code. You might ha...
Greetings,
I've been adding unit tests to some legacy C++ code, and I've run into many scenarios where an assert inside a function will get tripped during a unit test run. A common idiom that I've run across is functions that take pointer arguments and immediately assert if the argument is NULL.
I could easily get around this by disabl...
Hi all,
I didn't figure out a better title for the question. Let me explain it better now:
The project I am working on is going to connect to a remote server, encrypt the session and send/receive data packets.
I'd like to make it modular enough, so I thought it'd be nice to use 3 distinct classes. These would be:
1) A socket wrapper cl...
I need to expose some C++ classes to C# (I am building on Linux, using mono, so COM is not an option)
The evidence I have gathered so far suggests that the best way to approach this is:
Write a wrapper C++.Net class around the ISO C++ class
Consume the C++.Net classes from C#
I have the following questions:
First, is this the "bes...
Here is data structure w/ variables:
struct Part_record
{
char id_no[3];
int qoh;
string desc;
double price:
};
---
(Using "cin" to input data)
---
Part_record null_part = {" ", 0," ",0.0};
---
---
file.seekg( -(long)sizeof(Part_record), ios::cur);
file.write( ( char *)&part, sizeof(Part_record) ...
This is an embarrassing question, but even the well-written documentation provided with boost.interprocess hasn't been enough for me to figure out how to do this.
What I have is a cached_adaptive_pool allocator instance, and I want to use it to construct an object, passing along constructor parameters:
struct Test {
Test(float argume...
I'm using Code::Blocks to compile a shared library on Ubuntu. When I make a simple main.c file with:
void* CreateInterface()
{
int* x = (int*)malloc( sizeof( int ) );
*x = 1337;
return x;
}
This works fine and I can find the function CreateInterface with dlsym in another application. However, I want the function to create ...
As I found out that I can use only numerical values in C++'s switch statements, I thought that there then must be some deeper difference between it and a bunch of if-else's.
Therefore I asked myself:
(How) does switch differ from if-elseif-elseif in terms of runtime speed, compile time optimization and general compilation? I'm mainly ...
Hi all! I have a class, let's call it A. It has a enum (E) and a method Foo(E e), with gets E in the arguments. I want to write a wrapper (decorator) W for A. So it'll have its own method Foo(A::E). But I want to have some kind of encapsulation, so this method should defined as Foo(F f), where F is another enum defined in W, that can be ...
Before anything, I apologize if this question has been asked before.
I am programming a simple packet sniffer for a class project. For a little while, I ran into the issue where the source and destination of a packet appeared to be the same. For example, the source and destination of an Ethernet frame would be the same MAC address all o...
Hi All,
in a pre-compiled header if I do:
#define DS_BUILD
#define PGE_BUILD
#define DEMO
then in source I do:
#if (DS_BUILD && DEMO)
---- code---
#elif (PGE_BUILD && DEMO)
--- code---
#else
--- code ---
#endif
Do I get an error that states: error: operator '&&' has no right operand
I have never seen this before. I am...