I have been getting a really annoying error about an std::out_of_range when calling substr. The exact error is
terminate called after throwing an
instance of 'std::out_of_range'
what(): basic_string::substr
I'm absolutely sure that tmp_request has a length greater then 1. No matter what I pass to substr1, 2, or bodyposit alwa...
Boost.Asio is great library but it has one huge drawback -- extreamly slow compilation times. A simple implementation (really simple) of HTTP protocol (about 1k lines of code) requires about 13.5s to compile under GCC 4.4!
I tryed to use PCH but it does not improve compilation times too much (about 1s. only).
So are there any tutorials...
I want to wait on a condition for up to 1 second. I've try passing in time_duration:
boost::posix_time::time_duration td = boost::posix_time::milliseconds(50);
readerThread_cond_.timed_wait(lock, boost::bind(&XXXX::writeCondIsMet, this), td);
but I get the error:
/usr/include/boost/thread/pthread/condition_variable.hpp:156:
erro...
I wrote some very simple code since I'm just starting C++ and I want to get warmed up with the syntax and compiler before our binary tree assignment.
#include <iostream>
using namespace std;
int main(){
cout << "Hello";
return 0;
}
The only output I'm receiving is:
1> Build started: Project: First-BinaryTree, Configuration: Debug...
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(void)
{
int i=0;
while(i<10)
{
printf("%d", i);
usleep(10000); // or sleep(1)
i++;
}
return 0;
}
I want the program to last 10 secs, i.e. print 1 - wait 1 sec - print 2 - wait 1 se...
I have this original C++ function called "s":
long s(long n) {
long sum = 0;
long m;
m = (long) sqrt(n);
for (long i = 2; i < m; i++)
if ((n % i) == 0) sum += (i + (n/i));
if (n>1) sum += 1;
if ((m*m) == n) sum += m;
return sum;
}
I've been struggling to convert this function over to using the GMP's mpz type, so tha...
I'm trying to make a card game where the cards fan out. Right now to display it Im using the Allegro API which has a function:
al_draw_rotated_bitmap(OBJECT_TO_ROTATE,CENTER_X,CENTER_Y,X
,Y,DEGREES_TO_ROTATE_IN_RADIANS);
so with this I can make my fan effect easily. The problem is then knowing which card is under the mouse. To...
Hi all,
recently i discovered in a relatively large project, that ugly runtime crashes occurred because various headers were included in different order in different cpp files.
These headers included #pragma pack - and these pragmas were sometimes not 'closed' ( i mean, set back to the compiler default #pragma pack() ) - resulting in d...
Is the wchar_t type required for unicode support? If not then what's the point of this multibyte type? Why would you use wchar_t when you could accomplish the same thing with char?
...
I have a C++ Program listening for incoming socket connections on port 2222.
I have an Adobe AIR/Flex application that attempts to connect to it, when I click a button.
When I Connect To My Socket Over My Intranet, My C++ program hears and accepts the incoming socket connection and Everything Works Fine:
var Sock:Socket=new Socket("192...
So I was doing some simple C++ exercises and I noticed an interesting feat. Boiled down to bare metal one could try out compiling the following code:
class nice
{
public:
nice() {}
};
int main()
{
nice n;
return 0;
};
The result is a compilation error that goes something like this:
<file>.cpp: In function ‘int main()’:
<fi...
Anyone have idea on this? Linker errors are way out of my wheelhouse, especially ones like this.
Thanks for any help provided. ^_^
Is there any more info I should include?
1>Linking...
1>freeglut_static.lib(freeglut_window.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
1>LIBCMTD.lib(dbgheap.obj) : ...
How do compilers know how to correctly handle this code?
struct Foo
{
int bar;
Foo()
{
bar = 3;
}
Foo& operator=(const Foo& other)
{
bar = other.bar;
return *this;
}
int SetBar(int newBar)
{
return bar = newBar;
}
};
static Foo baz;
static Foo someOtherBaz = baz...
I've written an iPhone program which includes a library. The library uses some C++. The program runs fine in the simulator as long as debugger is turned off.
GDB immediately complains with the following
/SourceCache/gdb/gdb-962/src/gdb/dwarf2read.c:7593: internal-error: could not find partial DIE in cache
A problem internal to GDB ha...
I am getting linker errors lnk2001. i am very new to vs2008 and not sure how to make my prog work with cryptopp library. know how to link it? instruction so i don't get that undefined symbols stuff?
...
Possible Duplicate:
How can I run an external program from C and parse its output?
Hi,
Could someone please tell us how to capture a result when executing system() function ?
Actually I wrote a c++ program that displays the machine's IP address, called "ipdisp" and I want when a sever program executes this ipdisp program, t...
I've seen a lot of games use something similar to a .DAT file or a specific file type that the game has for itself. I'm just beginning with C++ and DirectX and I was interested in keeping my information in something similar to a .DAT.
My initial conception was that it would hold information on the files you wanted to store within the .D...
im now currently developing a standalone c++ program that would list all the access URL in a browser and its corresponding response time....
at this point of time, i can already sniff all out and in going packets. i am using winpcap for this...
retrieved packets were filtered to by only those 'tcp port 80(http) or 443(https)'...
and kn...
I have 3 classes. In it's simplest form, it looks like,
class tree
{
public:
tree_node* find_node(const std::string& text) {
return factory.find(text);
}
private:
tree_node_factory factory;
}
class tree_node
{
public:
tree_node(const std::string& text) : text_(text) {}
const std::string& text() const {
...
I tried
const int i[] = { 1, 2, 3, 4 };
float f[i[3]]; // g++ cries "error: array bound is not an integer constant"
int main()
{
const int j[] = { 0, 1, 2, 3 };
float g[j[3]]; // compiler is happy :)
return 0;
}
What is the difference between the two aggregates? How come referring to a const aggregate's e...