Forum: C++ Aug 10th, 2009 |
| Replies: 3 Views: 534 I suggest you take a read through The Function Pointer Tutorials (http://www.newty.de/fpt/), particularly this one (http://www.newty.de/fpt/fpt.html#r_value).
I would use some typedefs to help:
... |
Forum: C++ Jul 21st, 2009 |
| Replies: 13 Views: 1,439 Sorry to respond to this late... but I wanted to post info also...
The getline() function has the obnoxious habit of returning a not good() stream for final blank fields...
For a single blank... |
Forum: C++ Jul 6th, 2009 |
| Replies: 30 Views: 1,490 I agree with AD that the FTP is probably what is going wrong.
FTP defaults to text mode. You must explicitly set it to binary mode before copying files. |
Forum: C++ Apr 3rd, 2009 |
| Replies: 5 Views: 559 Alas, I just googled it.
Try searching for things like "bresenham line circle ellipse algorithm".
Speed comes from doing the least to draw individual pixels. Hence, a lot of optimization comes... |
Forum: C++ Jan 31st, 2009 |
| Replies: 15 Views: 7,852 I just can't fathom why truly brain-dead things like system("PAUSE") keep being taught.
I can only presume it is because important things like security, process control, system resource... |
Forum: C++ Sep 24th, 2008 |
| Replies: 3 Views: 1,815 Yes, you really are asking an OS and SDK-dependent question.
If you are using something like SDL, then respond to the key events that SDL gives you. Most GUI/graphics toolkits will give you a way... |
Forum: C++ Sep 24th, 2008 |
| Replies: 11 Views: 874 Good grief. Only use TerminateProcess() to kill the unruly.
Otherwise, just ask it nicely: send it a WM_CLOSE message. If it doesn't respond in, say, 500 ms or so, use CreateRemoteThread()... |
Forum: C++ Sep 14th, 2008 |
| Replies: 9 Views: 1,051 If you read and write your files one byte at a time, endianness is not an issue.
However, bit order is always an issue. The first bit you write should be in bit position 0 of the first byte you... |
Forum: C++ Sep 13th, 2008 |
| Replies: 4 Views: 1,127 You need to keep track of how many bits you have "output" so far. When you get eight or more, output a byte.
unsigned char bits = 0; // the unwritten bits
int count = 0; // the number of... |
Forum: C++ Sep 6th, 2008 |
| Replies: 5 Views: 1,252 Google "mingw sdl" and take a look through the first few links.
If you haven't already, make sure to upgrade to the latest version of MinGW (Dev-C++ comes with a pretty old one).
Good luck! |
Forum: C++ Sep 1st, 2008 |
| Replies: 8 Views: 730 Yes, it is an encoding issue. I suspect that it comes from the way your editor is saving the text file.
There are several ways to 'encode', or store, character data.
There is the old char-sized... |
Forum: C++ Aug 31st, 2008 |
| Replies: 4 Views: 730 No, it is the same as all the files having a #define GRAPHICS
To have a value:
g++ -DGRAPHICS=1 --> #define GRAPHICS 1
if (GRAPHICS) will work if and only if GRAPHICS is always defined to have... |
Forum: C++ Aug 24th, 2008 |
| Replies: 12 Views: 6,567 Empty files will never do anything except exist. ("Existing is basically all I do!" --Fry)
It also sounds like there is something misconfigured with your Code::Blocks IDE. Have you been able to... |
Forum: C++ Aug 16th, 2008 |
| Replies: 18 Views: 3,860 In addition, you should have a removeBook() (or some such named) method(s) for the user's convenience. |
Forum: C++ Aug 15th, 2008 |
| Replies: 13 Views: 1,392 Use the STL
#include <algorithm>
#include <fstream>
#include <iostream>
#include <iterator>
using namespace std;
int main( int argc, char** argv )
{ |
Forum: C++ Aug 13th, 2008 |
| Replies: 10 Views: 985 With just a very quick glance, that notOptimized() function needs some help. A bitvector (or vector<bool>) is not a good choice in such a function. Sad, but it was optimized for space, not speed.
... |
Forum: C++ Aug 8th, 2008 |
| Replies: 2 Views: 415 Without even looking at your code, I will make a wild stab in the dark and say that you are using a Windows console to run your program?
If you are, right-click the icon on the console's title bar... |
Forum: C++ Aug 8th, 2008 |
| Replies: 15 Views: 1,415 semicolons
A semicolon by itself is considered a null statement, and has no meaning. Modern compilers will typically complain about them unless they explicitly terminate a statement. For example... |
Forum: C++ Aug 6th, 2008 |
| Replies: 15 Views: 2,027 Heh heh heh -- I couldn't resist iamthwee's challenge (sorry conan --look below for where to get a dictionary).
// boggle-solver.cpp
// Copyright (c) 2008 Michael Thomas Greer
//... |
Forum: C++ Aug 6th, 2008 |
| Replies: 18 Views: 1,195 Actually, putting that system pause in there contributed to my low opinion. You said that was an example of when he uses <cstring>.
gets() is pure evil and should be lynched at every opportunity.... |
Forum: C++ Aug 5th, 2008 |
| Replies: 15 Views: 2,027 How is your dictionary stored? If, like iamthwee suggests, it is a file with words in it, you can just search the file for the given word.
You can even use the STL for that:
#include... |
Forum: C++ Aug 4th, 2008 |
| Replies: 3 Views: 400 #include <iomanip>
#include <iostream>
using namespace std;
int main()
{
for (int n = 1; n < 6; n++)
cout << n;
cout << setw( 5 ) << right << (167) << "mm\n";
return 0; |
Forum: C++ Aug 4th, 2008 |
| Replies: 5 Views: 2,306 There is nothing more or less hard about C++ than any other programming language.
People fear C++ because it comes with a very large set of capabilities.
It can be used to program procedurally.... |
Forum: C++ Aug 3rd, 2008 |
| Replies: 8 Views: 1,761 In practice it doesn't impact performance.
What it does is make your code more usable, more correct, and easier to read.
All you ever wanted to know about const correctness... |
Forum: C++ Jul 26th, 2008 |
| Replies: 3 Views: 440 Olvidaste poner conullas al seis. while (producto != '6')
:$
Hope this helps. |
Forum: C++ Jul 7th, 2008 |
| Replies: 9 Views: 3,775 Ah, it is because seating is declared as a 2D array, but you are only indexing one dimension. Hence the error.
Did you mean to treat seating as a 1D array in your function? I'm not sure how you... |
Forum: C++ Jul 3rd, 2008 |
| Replies: 17 Views: 2,420 OK, I told you I'd get you an example. I don't want to spend a lot of time finding the libraries to do it and coding one, but I do have an old program I wrote many many moons ago, when I was still... |
Forum: C++ Jun 27th, 2008 |
| Replies: 7 Views: 1,353 That was just an example function I created. I expected that you would take the code you needed from it and put it in your own function.
I don't think that TTextBox::Text takes a std::string, does... |
Forum: C++ Jun 25th, 2008 |
| Replies: 5 Views: 1,533 If all you want is teletype output (like you get on the console, without any fancy graphics or fonts or etc) you can open the PRN or LPT1 device:
#include <fstream>
#include <iostream>
using... |
Forum: C++ Jun 13th, 2008 |
| Replies: 12 Views: 1,606 A char is guaranteed to contain 8 bits, at least. (And unless you are playing with really old hardware, like ancient vaxen, a byte is also 8 bits.) But the compiler is not required to store... |
Forum: C++ Jun 11th, 2008 |
| Replies: 8 Views: 503 Google "linked list".
I presume each node represents a single atom? |
Forum: C++ Jun 4th, 2008 |
| Replies: 12 Views: 1,100 Actually it does have it backwards...
foo = this->foo; != this->foo = foo;
? |
Forum: C++ Jun 4th, 2008 |
| Replies: 12 Views: 1,100 Depending on how the data is packed.
If it is packed (MSB...LSB) ARGB then
int alpha = (color >> (3 * 8)) & 0xFF;
int red = (color >> (2 * 8)) & 0xFF;
int green = (color >> (1 * 8)) & 0xFF;... |
Forum: C++ May 31st, 2008 |
| Replies: 10 Views: 2,261 That's because you are actually creating two different types of structure.
In C and C++, arrays are something of a mixed bag.
When you declare
int a[ 10 ][ 5 ];
What is actually allocated... |
Forum: C++ May 29th, 2008 |
| Replies: 21 Views: 3,688 Wow, I'm really surprised to see AD so boiled up over something like goto.
(I thought you were cool man.... *sniff* --- heh heh heh)
Actually, you'll notice that goto still exists in many... |
Forum: C++ May 28th, 2008 |
| Replies: 3 Views: 468 Your loop encompasses both the menu and the selector, as:
do {
display_menu();
select_option();
while (!done);
So if the option is bad, the menu gets displayed again anyway.
What... |
Forum: C++ May 28th, 2008 |
| Replies: 11 Views: 899 Yes, OK. Your routine should terminate when you hit one, not -1. (You've got it right for the last three clauses of your code -- the stuff handling the positive numbers.) The trick is what happens... |
Forum: C++ May 28th, 2008 |
| Replies: 7 Views: 2,254 You are correct. The process file table and the current working directory are not modified by exec(), so the new executable inherits it all. |
Forum: C++ May 28th, 2008 |
| Replies: 4 Views: 438 Of course, once you get the whole line, you'll want to parse it using a stringstream and getline() again...
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
... |
Forum: C++ May 27th, 2008 |
| Replies: 5 Views: 880 IMO, interfacing with the user is one of those things that needs to be absolutely bullet-proof.
There are two things to keep in mind here:
1. How does the user expect to interact with your... |