c++

Need a short, complicated C++ code and a longer, understandable version

In this question, I tried to give an example of two ways of doing the same thing in C++: one short but complicated "fancy" piece of code; and a longer but more readable and understandable way of doing the same thing. The question asks whether it's better to have a well-commented fancy piece of code or a self-commented (i.e. no comments) ...

How to add node at some specific index in a linked list?

void insertLoc(int n, int i) inserts a node with info n after the ith location in the list. If the ith location does not exist in the list then the program should exit with an error message. Can anyone help me with the code please... #include<iostream> #include<process.h> using namespace std; struct node { int info; node *n...

10038 socket error

Is there any solution for 10038 server error .i have done coding in c++; the server runs fine 10 to 12 hours but sudenly it gives 10038 socket error ...

Problem with organizing files in Visual C++ project

Hi to all, I'm writing a project in Visual C++ 2010 Express edition. Everything was fine before i tried to add new source file in the project. Then when i tried to include one of the header files the compiler said that the class declared in this header is not found in other source file which includes the same header file. This is out...

what does this mean ?

int *temp = new int[atoi(argv[3])]; what does the above statement mean ?Please explain in detail . ...

Calculating co-ordinates for a sprite in C++

I am trying to calculate the angle of movement for a sprite in C++. Although at the moment I am just using the console to output my results. My problem is that when My results are shown in the console, I cannot get the x axis to go into minus numbers. Unfortunately I have only just learned about basic trig so I have no idea if I am ju...

what's the safe way to fill multidimensional array using std::fill?

Here's what I'm using: class something { char flags[26][80]; } a; std::fill(&a.flags[0][0], &a.flags[0][0]+26*80, 0); (Update: I should have made it clear earlier that I'm using this inside a class.) ...

Windows aplication that lives only in the taskbar

I'm new to windows programming (any win 32 API). I want to create a windows application that listens to the clipborad all the time and reacts to keyboard shortcuts (for example you copy text from the ClipBoard and press Ctrl-F and something is done on the text in the clipboard). I know how to make a window app in win32 and in C# (.NET) b...

Check if windows shell has finished loading startup programs

How can i programatically check if the windows shell (explorer) has loaded all startup programs & the user login process is over ? ...

Name convention for deleting data in C++

Assume I have some C++ method which returns back a pointer to an object. Something in the header file that looks like this: uint8_t* getData(void); This guy returns a byte array, but there is nothing that says if this is a dynamic or statically generated piece of data (local to the class or created with new). Is there a specific nami...

Why my prog can't run correctly?

// Calculate the quarters of a set of integers #include <iostream> #include <vector> #include <algorithm> #include <conio.h> using std::cin; using std::cout; using std::endl; using std::vector; using std::sort; int main() { // Ask for a set of integers cout << "Please input a set of integers: " << endl; // Read the set of integ...

Does it ever make sense to overload unary operator &?

So, C++ allows overloading the unary operator &(address). Are you aware of any real-world example when operator & was rightfully overloaded? And a second, more specific question, are you aware of any real-world example when operator & was rightfully overloaded while preserving address semantics? TIA ...

Set_union/Set_intersect for more than two sets in c++

I know those commands are for two sets. Does there any simple and fast way to do this for more then two sets. I think I can use some kind of loop for this but maybe there are better way. Thank you ...

print a screenshot of the desktop and convert in to a matrix of pixels[0,1]

Hi I want to build a program that prints the current screen (every few seconds) and searches for symbol in it. I already have the function that knows how to find a given symbol in a larger function, however I do not have the followings: How can i capture the current screen (print screen). How do i convert the picture into a matrix of ...

Passing PChar / *char between C++ and Delphi DLL

I have a C++ program, that calls Delphi DLL to initialize a buffer that contains chars. I am testing out the interface to make sure the data are passed correctly: In C++ program: char * pMsg = (char*)malloc(3); //allocate buffer Init(pMsg * char); //Delphi DLL function In Delphi DLL: procedure Init(pMsg:PChar); var pHardcodedMsg...

Issue while designing B+Tree template class in C++

Hi, I'm trying to write a generic C++ implementation of B+Tree. My problem comes from the fact that there are two kinds of nodes in a B+Tree; the internal nodes, which contain keys and pointers to child nodes, and leaf nodes, which contain keys and values, and pointers in an internal node can either point to other internal nodes, or le...

size_t and unsigned int does not match in a template function's parameter list

I want to use a stack to store indices of an array,so I use the following typedef,where istack is a template class for stack: typedef istack<size_t> IndexStack; and I declare a stack by IndexStack stack; But when I call the following function (where A.size() returns a size_t); stack.push_back(A.size()); GCC gives the follo...

C++ can int be NaN?

Hi, can I set an int to NaN? if yes then how can I check if an int is NaN or not? ...

int a; ...; (a == a) fails?

Hi, if we set float and double type to NaN then they are not equal to anything including themselves. can such a thing happens for int? ...

Why Is SDL_image not working

I am new to C++ and SDL; I am trying to add a new SDL extension libary using instructions found here: http://www.lazyfoo.net/SDL_tutorials/lesson03/windows/devcpp/index.php But I get these errors: 3 C:\Documents and Settings\Edmund\My Documents\C++\myprojects\SDL\SDLevent.cpp SDL/SDL_image.h: No such file or directory. C:\Documents ...