c++

2d array addition

This program adds two matrices but it's giving too many errors and I can't solve them. Errors: ARRAY BOUNDS MISSING and EXPRESSION SYNTAX Any ideas? #include<stdio.h> #include<conio.h> #define ROW=3 #define COL=3 int result[][COL]; void input(int arr[][COL]); void add(int mat1[][COL],mat2[][COL]); void print(int result[][...

C++: Struct initialization and maps

This works fine: #include <iostream> #include <map> using namespace std; struct Bar { int i; int f; }; int main() { map<int, Bar> m; Bar b; b.i = 1; b.f = 2; m[0] = b; } But if I want to make it a little more concise, I get errors: int main() { map<int, Bar> m; m[0] = {1, 2}; } Is th...

typedef struct : Default Initialization

typedef struct foo { bool my_bool; int my_int; } foo; In the example above I understand that my_bool will be initialized randomly to either true or false but what about my_int? I assumed that my_int would be default initialized to 0 but that seems not to be the case. Defining structs in this way appears to be incompatible wit...

FILE_NOTIFY_CHANGE_SIZE and FindFirstChangeNotification behavior in W7 and XP

Hello, I'm using a small program that notify me when a file size change inside a directory. The program worked perfect under Win XP, now in Windows 7 the size changes are ignored for long periods and notifications are not in sync with the changes. At first glance that could be seen as something related to caching/flushing differences ...

Properly writing to a nonblocking socket in C++

I'm having a strange problem while attempting to transform a blocking socket server into a nonblocking one. Though the message was only received once when being sent with blocking sockets, using nonblocking sockets the message seems to be received an infinite number of times. Here is the code that was changed: return ::write(client, mes...

g++ Double Free or corruption...But How??

Hi all, I seem to be having problems with my code and wondered if you guys could help me locate the problem...I have tried using gdb and valgrind, the latter being 'more' useful but still i am unable to fix my bug. Below is my code for my classes (This is my shrunk down version but the main essence of the problem persists): /* Vector....

Techniques to prevent overdraw (OpenGL)

I'm drawing lots of semi transparent polygons. My scene is 2D and uses 2f verticies. I can't use the depth buffer since it wont help because of alpha blending. What are some other techniques to reduce overdraw since this is what is crippling my application, not polygon counts since I use VBO's. Thanks ...

Combine two constant strings (or arrays) into one constant string (or array) at compile time

In C# and Java, it's possible to create constant strings using one or more other constant strings. I'm trying to achieve the same result in C++ (actually, in C++0x, to be specific), but have no idea what syntax I would use to achieve it, if such a thing is possible in C++. Here's an example illustrating what I want to do: #include <st...

boost::iterator_facade and std::find(...)

Below is an implementation of an iterator_facade for a linked list node. It's pretty much the same as that presented in the docs except it has a Value* dereference type instead of Value&. The problem is with using the iterators with std::find, it throws these compile errors for the find template. edit One Several noted that std::find ...

Link lists in C++

Hey guys, sorry for, but I'm new to doubly-linked lists and was wondering if anyone could tell me why my program crashes when i use add_end()? #include <iostream> using namespace std; node *start_ptr = NULL; node *current; int option = 0; void add_end() { node *temp, *temp2; temp = new node; cout << "Enter name: ...

Can't get my array numbers to compare to the other set.

I have two arrays that both hold 5 sets of random numbers. First I display a list of all the numbers in the first array; then I need to add to that list, any number that's not in the first array, and display each of those. To do that, I use another array to put the unique values in to display. I already have a function that displays the...

Best way to make a QToolBar of "checkable" QToolButtons where only one of the buttons can be checked at a time?

I'm looking to make a QToolBar with a few actions in it, each of which is "checkable" (that is, I call setCheckable(true) on each action after creating it, which leaves the button in the down state after clicking it). The only way I can think of "unchecking" the other buttons is to hook into each button's triggered signal and uncheck th...

How to find out DC's dimensions?

This might be rather trivial, however, after massive amounts of Googling, i haven't been able to find an answer. Let's say I have a handle to device context (naturally, in Windows environment): HDC hdc; How can I get the width and height of it? ...

Zooming into the mouse position with a translation?

To zoom into the mouse position I was using: glTranslatef(current.ScalePoint.x,current.ScalePoint.y,0); glScalef(current.ScaleFactor,current.ScaleFactor,current.ScaleFactor); glTranslatef(-current.ScalePoint.x,-current.ScalePoint.y,0); so basically I translate to the new origin (the mouse position) then scale by the current sc...

How to get parent node of element using tinyxml

Is there a way to get a parent node from a TiXmlElement? For example... TiXmlElement *parent = child->ParentElement( "someName" ); If you can't do this in tinyxml, are there any other xml parsers that allow this? ...

How does char *blah = "hello" work?

When you make a string out of char pointers how does this work? char *name = "ben"; Is this 'hidden' pointer arithmetic? ...

Getting the points from wglUseFontOutlines?

I'm making a vector application for Windows. Right now i'm using wglUseFontOutlines to generate display lists which wrks well, except I would like to be able to let the user remodel the font. I would also like to use VBO's instead of DL's for this. Does Microsoft provide a way to get the points for this, or atleast the outlines, I could ...

Consistenty header file names between C++ libraries

In my project I use two libraries, v8 and boost. Boost uses the .hpp extension for its headers, while v8 uses the .h extension for its headers. In the end of day, my source code starts like that: #include "v8.h" #include "boost/filesystem.hpp" ... In other question I asked about this subject, the general answer was that it is okay, b...

sorting strings in a file

hello guys! I need a solution for sorting of unix pwd file using C++ based on the last name. The format of the file is username, password, uid, gid, name, homedir, shell. All are seperated by colon delimiters. The name field contains first name follwed by last name both seperated by space I am able to sort the values using map and i am...

C++ User Input When Initializing Values

Hello. I'm a student in an introductory C++ course. For one of our past assignments we have had to create a simple program to add fractions. Each new lab is just an application of new skills learned to making the same program. Now I need to make one using objects from a class definition. After tooling with a multiplying example my pro...