I'd like to add that you really, really shouldn't use:
char *name3 = "Chennai" , *name4 = "Chennai" ;
As the strings are constants. Changing them will result in undefined behaviour (usually...
Type: Posts; User: EVOEx
I'd like to add that you really, really shouldn't use:
char *name3 = "Chennai" , *name4 = "Chennai" ;
As the strings are constants. Changing them will result in undefined behaviour (usually...
As already posted in the other thread: map.find(str.substr(index,4))->second may crash, if map.find(...) returns map.end(). You should compare it to that before you dereference the iterator.
One possibility is that map.find(...) returns map.end(). map.end()->second is not valid.
Actually, I take that back. Apparently he *was* acting on 4 characters at a time. Though to be fair,...
Ah, I misread the OP. I thought he acted upon groups of 4 characters, ie. in the first loop iteration read/write the character with indices 0 through 3. I see now that there is little reason to...
Imagine a three character string, "abc".
i = 0, so i < str.size() (= 3). The loop body will execute and assume there are 4 characters, reading past the end of the buffer. Instead, you'll want:
...
You definitely should NOT be using strcat. You should be reading in a C++ string (std::string), not a C-string (char buf[...]). After that, you can simply add it by saying either:
buf2 += '*';...
The class is written to take "std::istream" to process the arguments. std::istream is not specific to std::cin, std::istringstream is derived from std::istream as well. So you should just be able to...
Ok thanks for your answer! I'm going to spend some time considering this ;-).
Thanks for your reply! I think I agree with that - though many event based systems do seem to allow a return value.
Anybody who disagrees with this?
Hi everybody,
I'm considering implementing a general purpose event-based system in C++. Events will be asynchronous. My question regarding design is: should event handlers have a return value, or...
Right. I didn't even know I had the "clang" command. Mac's a bit of a mess compiler wise. See:
$ cat /tmp/a.c
#define F2(x, y) x##y
#define F1(x, y) F2(x, y)
#define TEST(x) F1(x,...
Yes, __LINE__ worked, __COUNTER__ didn't. As I explained in the second post, __COUNTER__ isn't expanded at all (it did work with make as it used gcc, it didn't with gcc as it used llvm). But...
Actually, it seems that __COUNTER__ doesn't work at all. It seemed to work when I compiled with "make", as my Mac is a bit of a mess with several compilers installed. But even a basic app like this:...
Hi everybody,
I'm using the LLVM compiler at the moment. I've written the following (test) code:
#define F2(x, y) x##y
#define F1(x, y) F2(x, y)
#define TEST(x) F1(x, __COUNTER__)
...
A few comments:
1. To debug segfaults, run the application through valgrind. Simply install it, and prepend "valgrind" to the command, and voila, you know where it crashed and why.
2. The usleep...
Thanks for your replies!
Actually, I've found a big issue with my method: the fact that it doesn't seem to be able to derive the type of the constructor's arguments. For example, for a matrix, if...
Hi everybody,
I'm working on a vector class - the mathematical kind - for C++11. I'm trying to find a decent way for initialization, such as:
Vector<3> v{ 0, 1, 2 };
My first idea was to...
Ahh, that makes sense, thanks!
The reference I was looking at (allocator - C++ Reference) completely ignores rebind...
Thanks!
Hi everybody,
I was looking through custom allocators. For example std::set is defined as follows:
template < class Key, class Compare = less<Key>,
class Allocator =...
Thanks for your answer!
Of course I'm not going to make a PHP daemon for this purpose, that was in reply to MK27's comment that PHP can be fast enough for this just fine. Of course I could...
Thanks for your replies guys!
But my issue with a multiplier is that the score has to be calculated for each row in the table, for each user. If the number of rows and/or the number of users...
Hi everybody,
I'm building a website in which I want to match events (concerts, fun thing to do in the area, etc.) to users. These events should be constrained to a location on either a country,...
Okay, makes sense now... Thanks very much, guys!
I guess I didn't understand volatile as well as I thought, then (sorry for my confusion). The code more accurately looks like this (should've written this in the first place):
class SomeClass {...
There were some changes I hadn't read ;-). But what exactly do you mean by "an atomic"?
Also, if I would have an object in the class, say:
std::queue<Task*> tasks_;
Would this need to be...