c++

Getting an Xcode project's resources in c++

I'm coding a simple game using SFML in Xcode. I have a .png of a block I want to use in a sprite. At the moment, I have to type the full path to the image in the code snippet below: sf::Image blockImage; if (!blockImage.LoadFromFile("/Users/me/Development/Tetris/images/block.png")) { cerr << "Could not load block image." << endl; ...

MySQL BLOB field INSERT syntax

Hi I'm writing a network server program in C++ which receives binary packets from network. Packets are then stored in std::vector< unsigned char > I've used MySQL 5.1 and MySQL Connector/C++ from ubuntu lucid to store packet information (field by field) into a table in a database. However, I also need to store the complete binary form ...

Problem using SysMonthCal32 window in Windows

I am using SysMonthCal32 windows in my application and I am seeing some strange problems while using it. The problem is regarding sending keydown event to calendar window. As per msdn documentation, if the window handles the message, it should return 0. The problem is whatever key i passes to the calendar window, it returns 0. This caus...

scanf() with C++ enums

The following is a typical situation in our codebase. enum ConfigOption { CONFIG_1=1, CONFIG_2=2, CONFIG_3=3 } ConfigOption cfg1, cfg2; sscanf(s, "%d", &cfg1); This is an internally used simulation software. Not distributed. Ease of maintenance and correctness are important. Portability and user interface -- not really. The troubl...

What can I do to avoid TCP Zero Window/ TCP Window Full on the receiver side?

Hi everyone, I have a small application which sends files over the network to an agent located on a Windows OS. When this application runs on Windows, everything works fine, the communication is OK and the files are all copied successfully. But, when this application runs on Linux (RedHat 5.3, the receiver is still Windows) - I see in...

check if compilator supports boost library

i am using visual c++ 2010 and want to check if it supports boost library and if not how download it?can i do it? ...

shortening the period of two dimensional dynamic array algorithms in C++

Hello , I defined two dimensional dynamic array and allocate memory for arrays.Dimensions of arrays are same as each other(256*256): double **I1,**I2; int M=256; int N=256; int i,j; I1= new double *[M+1]; for(i=1;i<=M;i++) {I1[i]=new double [N+1];} I2= new double *[M+1]; for(i=1;i<=M;i++) {I2...

how do i define 24 bit array in c++?

how do i define 24 bit array in c++? (variable declaration) thank you ...

Windows Logoff Event c++

Hello, I need to catch windows logoff event, I'm using c++. I dont know where to start searching, thanks for any help, Dani. ...

C++ / Qt : passing variables to be changed in the class

Hello, So I have two forms in my project: MainWindow and Options Form (OptForm; QWidget); Now, I create (simply dragging to a form) a QPushButton in MainWindow to open OptForm, and passing in variables, which OptForm can change. void MainWindow::openOpt() //Slot; QPushButton calls(?) it { OptForm w (this->variable1,this->variable2,...

Which location address in a pointer refers to

Hi, What does the address in a pointer refer to, real address location in main memory or virtual address. Can it be configured. And if it refers to virtual address , does Memory manager needs to convert this address to real address everytime it is accessed ...

How can I return a value from a class object?

Is it possible to have a class object return a true/false value, so I can do something like this: MyClass a; ... if (a) do_something(); I can accomplish (almost) what I want by overloading the ! operator: class MyClass { ... bool operator!() const { return !some_condition; }; ... } main() MyClass a; ... i...

Use the auto keyword in C++ STL

I have seen code which use vector, vector<int>s; s.push_back(11); s.push_back(22); s.push_back(33); s.push_back(55); for (vector<int>::iterator it = s.begin(); it!=s.end(); it++) { cout << *it << endl; } It is same as for (auto it = s.begin(); it != s.end(); it++) { cout << *it << endl; } How safe is in this case the use of...

Dedicating a field in arbitrary class types for "external use"

My container needs to store a little information about its elements. Normally, I store this separately from elements. However, I'd like to give users possibility to conserve memory by dedicating a field in element structure type for external use. E.g.: struct MyStuff { int foo; char bar; mutable char dedicat...

sort vector of string using templates

here is code for sort vector of string #include<iostream> #include <vector> #include <functional> #include <algorithm> #include <ostream> using namespace std; //using std::greater; int main(){ vector<string>s; s.push_back("cat"); s.push_back("antelope"); s.push_back("dog...

How do I code and pass a (reference to a std::vector)?

I can't seem to get this right. class Tree { Node* root; vector& dict; } class Node { vector& dict; char* cargo; Node left; Node right; } I want each instance of Tree to have it's own dict, and I want it to pass a reference to the dict to the node constructor, which would recursively pass the refere...

simplify simple C++ code -- something like Pythons any

Hi, Right now, I have this code: bool isAnyTrue() { for(std::list< boost::shared_ptr<Foo> >::iterator i = mylist.begin(); i != mylist.end(); ++i) { if( (*i)->isTrue() ) return true; } return false; } I have used Boost here and then but I couldn't really remember any simple way to write it somewhat lik...

boost gzip reading files with trailing garbage

Hey, I'm using boost::iostreams::gzip_decompressor with boost::iostreams::filterimg_streambuf to read gzip files. some of my files have what zcat calls trailing trash % zcat somefile data data data gzip: somefile: decompression OK, trailing garbage ignored What I want is for boost gzip to behave the same way. When trying to decom...

Returning From a Void Function in C++

Consider the following snippet: void Foo() { // ... } void Bar() { return Foo(); } What is a legitimate reason to use the above in C++ as opposed to the more common approach: void Foo() { // ... } void Bar() { Foo(); // no more expressions -- i.e., implicit return here } ...

What is the common denominator XML library across Linux and Windows for parsing XML in C or C++?

I want to parse some XML in a C and C++ app. This app is deployed to Windows and Linux. What is an XML library that is likely to be installed on many Linux distributions and is readily available on Windows? From my samples of Linux distros, libxml2 seems to be fairly common, but is there a more common xml library? ...