c++

[C++] Real time plotting/data logging

I'm going to write a program that plots data from a sensor connected to the computer. The sensor value is going to be plotted as a function of the time (sensor value on the y-axis, time on the x-axis). I want to be able to add new values to the plot in real time. What would be best to do this with in C++? Edit: And by the way, the progr...

how to start building cooliris in openGL and C++?

I have seen the post where somebody commented that cooliris can be built using C++ and openGL. I have just started learning openGL. I wanted to ask how to go about creating it? ...

Which one is faster, reading from disk or allocate system memory

Hi guys, My environment is XP 32-bit. I find when allocated memory is nearly the maximum size, 2GB, that means a little virtual space is available, allocationnew memory is very slow. So if I have a page file, my app need to analyze them. I have two ways. One is to read them all into system memory, then do the analysis. The other is to...

Correct way to distribute VC++ runtime files

I have an MFC application which I am trying to package for deployment. It seems to depend on the files 'msvcr90.dll', 'msvcp90.dll' and 'mfc90.dll'. What is the correct way to distribute these files? I can't use merge modules as my installer doesn't support them. I know I can run VCRedist_x86.exe, but I don't want to do this for various...

Using a.vim for C++

is there a way to use the a.vim plugin to switch between .h, .cxx and .txx files? Alternatively, can you provide another solution? The idea is to automagically switch from .h -> .txx -> .cxx at the press of a key. A Big Thanks to both of you! ...

string initialization

It might be a silly question but is there any difference between std::string s1("foo"); and std::string s2 = "foo"; ? ...

Can two booleans be compared in C++?

Is the following piece of code supposed to work? bool b1 = true; bool b2 = 1 < 2; if (b1 == b2) { // do something } I suspect that not all 'trues' are equal. ...

To get reference counting, do I have to clutter my APIs with shared_ptr?

I recently had the following memory bug, which is easy to spot here, but can be harder to detect in more complex code: class Foo : public IFoo { const Bar& bar_; public: Foo(const Bar& bar) : bar_(bar) { } void test() { // access bar_ here } }; int baz() { IFoo* foo = NULL; if(whatever) { Bar bar; foo = new Fo...

unlink vs remove in c++

Hi. What is the difference between remove and unlink functions in C++? Thanks. ...

How do I decrypt a file with Crypto++ that was encrypted with C#

Hi all, I would like to decrypt a file that I previously encrypted with C# using the TripleDESCryptoServiceProvider. Here's my code for encrypting: private static void EncryptData(MemoryStream streamToEncrypt) { // initialize the encryption algorithm TripleDES algorithm = new TripleDESCryptoServiceProvider(); ...

How do I predict serious memory fragmentation issue is likely to happen?

Can I check the page fault time or something else.. :) ...

Macro / keyword which can be used to print out method name?

__FILE__ and __LINE__ are well known. There is a __func__ since C99. #include <iostream> struct Foo { void Do(){ std::cout << __func__ << std::endl; } }; int main() { std::cout << __func__ << std::endl; Foo foo; foo.Do(); return 0; } will output main Do Is there any macro / keyword that would output...

Help with understanding why UAC dialog pops up on Win7 for our application

We have a C++ unmanaged application that appears to cause a UAC prompt. It seems to happen on Win7 and NOT on Vista Unfortunately the UAC dlg is system modal so I can't attach a debugger to check in the code where it is, and running under msdev (we're using 2008) runs in elevated mode. We put a message box at the start of our progr...

Worst side effects from chars signedness. (Explanation of signedness effects on chars and casts)

I frequently work with libraries that use char when working with bytes in C++. The alternative is to define a "Byte" as unsigned char but that not the standard they decided to use. I frequently pass bytes from C# into the C++ dlls and cast them to char to work with the library. When casting ints to chars or chars to other simple types w...

Why this Dijkstra (graph) implementation isn't working ??

I made this implementation for this problem : http://www.spoj.pl/problems/SHOP/ #include<iostream> #include<stdio.h> #include<queue> #include<conio.h> #include<string.h> using namespace std; struct node { int x; int y; int time; }; bool operator <(const node &s,const node &r) { if(s.time>r.time) return true; e...

Does the STL contain a hashtable?

Possible Duplicates: Hashtable in C++? can anybody offer a simple hash_map example in C++? Does the STL contain an implementation of a hashtable? If so, can you provide a brief example of how to use it? ...

STL: how to overload operator= for <vector> ?

There's simple example: #include <vector> int main() { vector<int> veci; vector<double> vecd; for(int i = 0;i<10;++i){ veci.push_back(i); vecd.push_back(i); } vecd = veci; // <- THE PROBLEM } The thing I need to know is how to overload operator = so that I could make assignment like this: vector<double> = vector<int>; I'...

using boost::iostreams to read specifically crafted data, then based on that create object and append it to list

I have an interesting problem. Let's say that i have file with lines filled like this: name1[xp,y,z321](a,b,c){text};//comment #comment name2(aaaa); also I have (simplified) class: class something { public: something(const std::string& name); addOptionalParam(const std::string& value); addMandatoryParam(const std::string& value); ...

How do I require const_iterator semantics in a template function signature?

I am creating a constructor that will take a pair of input iterators. I want the method signature to have compile-time const semantics similar to: DataObject::DataObject(const char *begin, const char *end) However, I can't find any examples of this. For example, my STL implementation's range constructor for vector is defined as: tem...

Are files dumped with fwrite portable across different systems?

Can I assume a file generated with fwrite and read using fread is portable across different systems. 32bit/64bit windows,osx,linux. //dumping FILE *of =fopen("dumped.bin","w"); double *var=new double[10]; fwrite(var, sizeof(double), 10,FILE); //reading file *fo=fopen() double *var=new double[10]; fread(var,sizeof(double),10,of); And w...