Type: Posts; User:
September 17th, 2009,
Let's start by cleaning up the code, and more importantly placing it within CODE tags so that it is easier to read.
First, avoid using char arrays in C++; instead use the STL string container...
July 15th, 2009,
hoxsiew, you are correct; the fd_set (and the timeout period, if used) needs to be (re)set before each call to the select().
I found the problem to the issue I was having. The code, which I...
July 14th, 2009,
I am having an issue with an overzealous select() call. I works as expected until I send a single UDP message to my socket. Then it reports that there is activity even after the application...
I think you are misunderstanding the fundamentals that have been presented thus far in this thread.
The simplest approach to the issue you are having is to place the implementation of the template...
That's pretty nifty.
I'll concede to that argument.
I first saw the .impl extension being used when I dabbled with CORBA programming a few years ago.
I agree with what you have stated, but why would one do this unless they are short of RAM? The whole point of creating a template is to provide reusable code that can work with any object, those...
June 30th, 2009,
Try augmenting the size of your server's socket receiving buffer. Here's how with Linux C++; I do not know how well this translates to VC++.
const int size = 1470 * 100; // 1470 bytes * 100...
June 30th, 2009,
The implementation of templated code MUST be within (or included within) the header file.
template <class T>
Most s/w development projects have standards that differ from your opinion. But at the end of the day, do whatever pleases you (and your peers). Don't cry though when someday you have to maintain a...
Hopefully you will see this post; below is the minimum to get you on your way...
One of the keywords, or noun, in your statement is 'game'. You should have a class object that represents the Game, and it is within there, that you would declare your Player object(s), game-board,...
Never place a "using namespace" directive in a header file; it is considered poor programming practice.
Additionally, it would be better to define an enum or another type (e.g. static const...
There is not much information provided by the fstream exception, other than an error occurred when attempting to open or read from the file. Generally speaking, there really is no difference between...
This issue lies with the declarations of your functions. You really want to pass all of your parameters by reference, not by value. The error that you are getting is caused by your attempt to copy...
I also don't see the purpose of using fopen() when C++ provides the fstream (or more specifically, ofstream) class.
std::cout << "Enter filename:...
I find this hard to believe! The following code works fine:
std::fstream file("data.dat", std::ios::in);
The use of ctime() requires a time_t parameter. Why do you not use that same time_t parameter in either gmtime() or localtime() to yield the struct tm?
If that is not an option, then just use...
Would it not be helpful to have one of these statements inside that new while-loop you added:
Have you tried outputting the string 's' to the screen using std::cout?
int line = 0;
April 27th, 2009,
Actually, your usage of the struct timeval is correct. It is quite possible it is one of the other parameters is causing the error.
I normally do not perform the static_cast<int> as you have...
April 4th, 2009,
I figured this was for a class, and thus I provided a semi-advanced example. Take the code I wrote, an in lieu of the vector, pass the array as you had done. Within the choiceRead() function,...
April 3rd, 2009,
Initially when you prompt the user for a choice between encoding and decoding, only the numeric input is processed and stored in nSel. The newline character is still sitting in the cin stream, and...
April 3rd, 2009,
You are writing code in C++. You should avoid using a C-style array for storing values; use an std::vector instead. You do not need to keep track of its size, and thus is safer to use (there is no...
April 1st, 2009,
How about this:
int probability(const int low, const int high)
p = rand() % (high + 1);
March 21st, 2009,
Get this book and read it.
It's a starting point!
Click Here to Expand Forum to Full Width