c++

program not working as expected!

Can anyone just help spot why my program is not returning the expected output. This is related to my previous question. I am passing a vector by reference; I want to see whats in the container before I copy them to another location. If you remove comments on loadRange, youu will see bids are generated by the trader. #include <iostream> ...

Use boost date_time to parse and create HTTP-dates

I'm writing a kind of HTTP proxy, so I need to be able to do 3 things: Parse an HTTP-date given any of the 3 formats specified in RFC 2616, sec 3.3, Convert a file date-time to an HTTP-date string, and Output the date to a string. For reference, theses are examples of the date-times I need to parse. I will output only the first form...

How can I get the contents of a file at build time into my C++ string?

I have a file I am compiling in C++ in which I wish to have a string whose value is the contents of a file at the time of compilation. In other words, I'd like to #include the file but have that be inside double quotes. How can I do this in C++? Now what if that file contains double quotes as part of its text, how do I get those escap...

How to check for cancel button in custom action without doing anything else.

I know when I put something in the log using ::MsiProcessMessage(hModule, INSTALLMESSAGE(INSTALLMESSAGE_INFO), ...); that I can check if the return value is IDCANCEL and return ERROR_INSTALL_USEREXIT to Windows installer. How do I check for that return value without having to put something in the log or alter the progress bar? ...

Is the stack unwound when you stop debugging?

Just curious if my destructors are being called. (Specifically for Visual Studio, when you hit the red stop button) ...

Efficient update of SQLite table with many records

I am trying to use sqlite (sqlite3) for a project to store hundreds of thousands of records (would like sqlite so users of the program don't have to run a [my]sql server). I have to update hundreds of thousands of records sometimes to enter left right values (they are hierarchical), but have found the standard update table set left_va...

Unresolved external using C++Builder packages (with TForm-based classes)

I'm working with Borland C++Builder 6 and 2010, and am having this problem. However, the difference here is that i'm using a FORM compiled inside the package, so, take the example above, but in addition I'm including a form class, like TForm2: class TForm2 : public TForm { __published: // IDE-managed Components TButton *Button1;...

What is the most efficient way to find missing semicolons in VS with C++?

What are the best strategies for finding that missing semicolon that's causing the error? Are there automated tools that might help. I'm currently using Visual Studio 2008, but general strategies for any environment would be interesting and more broadly useful. Background: Presently I have a particularly elusive missing semicolon (or b...

Error while excuting a simple boost thread program

Hi All, Could you tell mw what is the problem with the below boost::thread program #include<iostream> #include<boost/thread/thread.hpp> boost::mutex mutex; class A { public: A() : a(0) {} void operator()() { boost::mutex::scoped_lock lock(mutex); } private: int a; }; int main() { boost::thread thr1(A()); boos...

Does this have anything to do with endian-ness?

For this code: #include<stdio.h> void hello() { printf("hello\n"); } void bye() { printf("bye\n"); } int main() { printf("%p\n", hello); printf("%p\n", bye); return 0; } output on my machine: 0x80483f4 0x8048408 [second address is bigger in value] on Codepad 0x8048541 0x8048511 [second address is smaller in v...

template warnings and error help, (gcc)

Hi there, I'm working on an container class template (for int,bool,strings etc), and I've been stuck with this error cont.h:56: error: expected initializer before '&' token for this section template <typename T> const Container & Container<T>::operator=(const Container<T> & rightCont){ what exactly have I done wrong there?. Also n...

Can someone code review my small SDL app? Want to make sure I didn't make any beginner mistakes

In an effort to teach myself the SDL library (hence my stack overflow handle :) ) I wanted to try my hand at a side-scroller. My code is complete but I want some feedback (mostly because I have an atrocious amount of if and else statements for what seems like some simple logic). My "program" is a c++ side-scroller where you move a singl...

How to test your code on a machine with big-endian architecture?

Both ideone.com and codepad.org have Little-Endian architechtures. I want to test my code on some machine with Big-Endian architechture (for example - Solaris - which I don't have). Is there some easy way that you know about? ...

Overload on reference, versus sole pass-by-value + std::move?

It seems the main advice concerning C++0x's rvalues is to add move constructors and move operators to your classes, until compilers default-implement them. But waiting is a losing strategy if you use VC10, because automatic generation probably won't be here until VC10 SP1, or in worst case, VC11. Likely, the wait for this will be measur...

creating a vector with references to some of the elements of another vector

hi, I have stored instances of class A in a std:vector, vec_A as vec_A.push_back(A(i)). The code is shown below. Now, I want to store references some of the instances of class A (in vec_A) in another vector or another array. For example, if the A.getNumber() returns 4, 7, 2 , I want to store a pointer to that instance of A in another...

why my C++ output executable is so big?

I have a rather simple C++ project, which uses boost::regex library. The output I'm getting is 3.5Mb in size. As I understand I'm statically linking all boost .CPP files, including all functions/methods. Maybe it's possible somehow to instruct my linker to use only necessary elements from boost, not all of them? Thanks. $ c++ —version i...

deleting an array that stores pointers to some objects

hi, I am storing pointers to elements of a vec_A in an array A* a_ptrs[3] . Assume that vec_A will not be resized. So, a_ptrs[i] will point to the correct element. My question is: Suppose A* a_ptrs[3] is declared in a class B. Since it is not created using 'new' I am guessing I don't need to delete it in the destructor. Am I right...

How do I convert a double into a string in C++(without scientific notation)?

How to convert a double into a floating-point string representation without scientific notation in C++. "Small" samples (effective numbers may be of any size, such as 1.5E200 or 1e-200) : 0.0000000000000000000000000000000000000000000000000000000023897356978234562 Thank you. ...

Class lookup structure array in C++

I'm trying to create a structure array which links input strings to classes as follows: struct {string command; CommandPath cPath;} cPathLookup[] = { {"set an alarm", AlarmCommandPath}, {"send an email", EmailCommandPath}, {"", NULL} }; which will be used as follows: CommandPath *cPath = NULL; string input; getline(cin, i...

Is there a .def file equivalent on Linux for controlling exported function names in a shared library?

I am building a shared library on Ubuntu 9.10. I want to export only a subset of my functions from the library. On the Windows platform, this would be done using a module definition (.def) file which would contain a list of the external and internal names of the functions exported from the library. I have the following questions: How ...