c++

Why does negative number show up when I do FFT on a Gaussian?

I'm using this fftw library. Currently I'm trying to plot a 2D Gaussian in the form e^(-(x^2+y^2)/a^2). Here is the code: using namespace std; int main(int argc, char** argv ){ fftw_complex *in, *out, *data; fftw_plan p; int i,j; int w=16; int h=16; double a = 2; in = (fftw_complex*) fftw_malloc(sizeof(fftw...

Need to make context available to C++ ostream insertion operators

For an API that I am working on, I want to allow the user to insert custom objects into an ostream, but these objects have no meaning on their own, and are too memory constrained to include an additional pointer or reference for context. (Think tens of millions of 16-/32-/48-bit objects in an embedded system with limited memory.) Suppo...

forward class friend declaration

Hi i have a problem, I try to do the follow, class A depends on class B and vice versa like this class A; class B{ A foo; friend B A::doSomething(); }; class A { B bar; B doSomething; }; The friend declartion does not work because A is an incomplete declartion. Is there any way to avoid this? (Swapp classes declaratio...

What puzzles me...Are .NET languages the mainstream languages for Windows (standalone) applications?

I'm an inquisitive .NET student without any commercial working knowledge and I have been puzzled by what exactlty are .NET languages meant for? Q1.If you look on job websites, .NET seems mainly used for web applications, not much for Windows applications? (My dream job is to develop standalone small Windows applications.) Q2.Are most ...

Winpcap saving raw packets not from an adapter.

I am trying to build an application that converts my old custom Ethernet logs (bin files) to standard winpcap style logs. The problem is that I can't seem to find an example of how to opening a pcap_t* without using an adapter (network card). The temp.pkt has not been created. I have looked thou the examples provided with Winpcap and...

Installing Allegro in Dev-C++ using their Packages

I'm trying to install Allegro in Dev-C++, and rather than do it manually, I noticed the new version was in the available packages, so that'd be easier. Here it is in the manager. Here it is showing itself containing the header file. And when I try to run the simplest of Allegro programs, it doesn't recognize it. Anyone know how to ...

How to concatenate using lstrcat in Visual C++?

Hi, I would like to append two strings together so that I can rename a file using the MoveFile function. But my strings refuse to concatenate, so instead of adding "E:\" to "FILE-%s-%02d%02d%02d-%02d%02d.txt" to give me "E:\FILE-%s-%02d%02d%02d-%02d%02d.txt", it gives me just "E:\" as if nothing happened. Here is a snippet of my full c...

Creating a Lua Table from a const char **

I have a const char ** which is going to be of varying lengths, but I want to create a lua array from the const char **. My const char ** is something like this arg[0]="Red" arg[1]="Purple" arg[2]="Yellow" I need to convert this array to a global table in Lua, but I'm not sure about how to go about this as I'm not very good at manipu...

What control style is this?

I want to make a control where the bottom is nice and beveled as seen here: http://img19.imageshack.us/f/finalzh.png/ What style must I add to my control to achieve the same look as this? Thanks ...

Anyone with experience on embedding CINT into a C++ app?

I'm talking about ROOT's CINT. I've been developing a game in c++ wich uses Python for programming the AI. As much as I love Python, and how easy it makes programming the AI (generators and FP are really sexy), it makes non trivial algorythms run so slow. Then I remembered I read somewhere about CINT, and how it can be embedable. N...

TOUGH: Dealing with deeply nested pointers in C++

I define this structure: struct s_molecule { std::string res_name; std::vector<t_particle> my_particles; std::vector<t_bond> my_bonds; std::vector<t_angle> my_angles; std::vector<t_dihedral> my_dihedrals; s_molecule& operator=(const s_molecule &to_assign) { res_name = to_assign.res_name; my_particles = to_assign.m...

Lua function return string with C++

Is it possible to add a function to Lua via C++ that returns a string? -edit- Ok, this code wont work. Any help? int flua_getinput(lua_State *L){ if(lua_isstring(L,1)){ cout << lua_tostring(L,1); cin >> input; cout << "\n"; lua_pushstring(L,input); }else{ cin >> input; cout << "\n"...

Add tabs in reverse order?

By default tabs get added from right to left, so if I insert 1,2,3,4,5 then the tabs will read 5,4,3,2,1. How can I make it read 1,2,3,4,5 thanks. http://img96.imageshack.us/i/ahhh.png/ This is obtained from inserting Untitled Project first and Untitled 5 last. What I would want would be for Untitled 5 to be selected at the far right ...

Header files included in multi .cpp files

Hello. I followed a simple example as below. But compile failed. Could you please have a look and give me some suggestion. vs2010 console application used.Thank you. Error message pgm.h(11): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int pgm.h(11): error C2143: syntax error : missing ','...

Parsing a line with a variable number of entries in C or C++ (no boost)

I have a file containing lines of the form, double mass, string seq, int K, int TS, int M, [variable number of ints] 688.83 AFTDSK 1 1 0 3384 2399 1200 790.00 MDSSTK 1 3 1 342 2 I need a (preferably simple) way of parsing this file without boost. If the number of values per line ...

Creating a control like this

How could I create a control that looks like this one: I just want that small end. Thanks ...

How does Snipping Tool do this?

I noticed that Snipping Tool (On Windows Vista / 7) has a Toolbar control. I'v used Spy++ and copied its exact styles but when I press down, it does not do like theirs. Theirs stays stuck on the clicked control, indicating that this tool is 'in use' I want to have this effect in my application. Thanks ...

Decorator vs Strategy Pattern (vs ?) to extend functionality

Hi, I've been trying to read through different implementations of Scene Graphs for 3D engine development to learn design patterns used in this domain, but unfortunately the code bases are too big for me grasp (yet, hopefully). So, let's say we have a class Model that stores pointers to geometry, shaders, textures etc. and we want to a...

build error with boost spirit grammar (boost 1.43 and g++ 4.4.1) part III

Ok i am trying to build a grammar and currently it looks like this: #ifndef _INPUTGRAMMAR_H #define _INPUTGRAMMAR_H #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <boost/spirit/include/phoe...

Calling shutdown and closesocket twice on same socket

In my application i am calling shutdown and closesocket function twice on same socket. I know this is not right thing to do and i have to ensure that these functions are called only once but why doesnt the shutdown socket or close socket fail when called second time. If m_Socket is having a value of 1500 what will its value be when shut...