Forum: C++ Aug 10th, 2009 |
| Replies: 3 Views: 486 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++ Aug 7th, 2009 |
| Replies: 7 Views: 366 A std::vector is guaranteed to maintan contiguous data space -- meaning it cannot handle really large data.
Use a std::deque instead. I looks much the same, but the data need not be stored... |
Forum: C++ Aug 7th, 2009 |
| Replies: 2 Views: 218 There is no simple answer.
You might want to look through The GUI Toolkit, Framework Page (http://www.free-soft.org/guitool/).
TrollTech Qt is a good choice if you can use it -- it has some... |
Forum: C++ Aug 7th, 2009 |
| Replies: 2 Views: 227 You should read up on virtual methods.
class Greeting
{
public:
// Here is our abstract, overridable method
virtual std::string hello() const = 0;
};
// Here is an example of... |
Forum: C++ Aug 7th, 2009 |
| Replies: 14 Views: 507 You don't need to use strcat()... Please don't suggest using the C string library to manipulate C++ strings.
AD already addressed your question. You should be using getline() to get user input:
... |
Forum: C++ Aug 6th, 2009 |
| Replies: 14 Views: 507 The first thing you need to do is break your dependence on the system() function. It spawns a new shell (cmd.exe, probably), changes the directory for that new shell, then terminates. Your program's... |
Forum: C++ Aug 6th, 2009 |
| Replies: 5 Views: 411 There are differences in the make between POSIX and Windows, as well as some problems with the MSYS make (which is POSIX, AFAIK).
You should be using your ~MinGW\bin\mingw32-make.exe program when... |
Forum: C++ Aug 3rd, 2009 |
| Replies: 2 Views: 281 It would, as VernonDozier suggested, be easy enough to code your own version...
Here's a simple stab at it:
#include <iostream>
#include <string>
std::istream& getline( std::istream& ins,... |
Forum: C++ Aug 3rd, 2009 |
| Replies: 6 Views: 341 I suggest SDL (http://www.libsdl.org/).
Take a look through Lazy Foo' Productions (http://lazyfoo.net/SDL_tutorials/)'s tutorials to get started.
There is also PyGame (http://www.pygame.org/),... |
Forum: C++ Jul 25th, 2009 |
| Replies: 10 Views: 569 In both instances you are misusing the GetCDHandle() (http://akrip.sourceforge.net/api/api3_4.html) function.
The function takes a pointer to an extant GETCDHAND struct.
HCDROM hcd;... |
Forum: C++ Jul 24th, 2009 |
| Replies: 11 Views: 9,906 Sigh.
#include <algorithm> // remove_if()
#include <cctype> // isspace()
#include <functional> // ptr_fun <>
#include <iostream> // I/O
#include <string> // string
using... |
Forum: C++ Jul 21st, 2009 |
| Replies: 13 Views: 1,332 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,462 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 9th, 2009 |
| Replies: 5 Views: 621 I don't currently have access to Solaris ATM... alas, but perhaps it is something as simple as needing a blank line after each target:
CC = cc
run: driver.o
CC -o run driver.o
driver.o:... |
Forum: C++ Apr 6th, 2009 |
| Replies: 2 Views: 766 Alas, the OP want's to know how to insert those obnoxious commas (,) in between digits.
Remember to use integer division and modulo (remainder) to split numbers apart (/ and %).
For example:
... |
Forum: C++ Apr 3rd, 2009 |
| Replies: 5 Views: 539 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++ Apr 2nd, 2009 |
| Replies: 5 Views: 539 http://www.cs.unc.edu/~mcmillan/comp136/Lecture7/circle.html
Hope this helps. |
Forum: C++ Apr 1st, 2009 |
| Replies: 5 Views: 539 Oy! Please don't use a vector (or any other STL container) to hold individual pixel data -- Just draw directly to the target surface.
Also, you needn't directly calculate every pixel in the... |
Forum: C++ Mar 30th, 2009 |
| Replies: 9 Views: 833 Certainly.
SetConsoleTextAttribute() (http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q=msdn+setconsoletextattribute)
Hope this helps. |
Forum: C++ Mar 29th, 2009 |
| Replies: 3 Views: 373 Choice of language often depends on one or more of the following
Business requirements
Applicability to the solution
Programmer's choice
For a succinct listing of Python's strengths, see... |
Forum: C++ Mar 29th, 2009 |
| Replies: 3 Views: 373 The best way to learn such things is to read the Python documentation.
Embedding Python in Another Application (http://www.python.org/doc/2.5.2/ext/embedding.html)
Hope this helps. |
Forum: C++ Mar 27th, 2009 |
| Replies: 4 Views: 389 Lousy timeout...
You don't actually have to fork(), just poll() or select() on the appropriate channels.
As for cin -- that is, by default, a line-buffered input (meaning, it blocks until the... |
Forum: C++ Jan 31st, 2009 |
| Replies: 15 Views: 7,578 LOL yeah, on bootlegged NT 4+ systems... XD |
Forum: C++ Jan 31st, 2009 |
| Replies: 5 Views: 1,611 Why do you want to do that?
(In other words, unless you are writing a full-screen text application like an editor or video game, don't do that.)
Otherwise, on Windows, see Example Two... |
Forum: C++ Jan 31st, 2009 |
| Replies: 15 Views: 7,578 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++ Nov 20th, 2008 |
| Replies: 14 Views: 1,159 >So there's absolutely no way possible for the average person to write to it?
No.
>I was just curious, I absolutely do not want to make any type of virus, trojan, or malware.
Anything that... |
Forum: C++ Nov 20th, 2008 |
| Replies: 10 Views: 808 The documentation for rename() plainly states that if a file with the new name already exists, results are implementation-defined. You are better off deleting any existing 'new name' file first.
... |
Forum: C++ Nov 20th, 2008 |
| Replies: 5 Views: 510 First off, you are being a bit pushy. Stop. Sometimes it takes a day or two to get a (useful) answer.
Secondly, if you can't use C++, then you are posting in the wrong forum.
A good DLL to... |
Forum: C++ Nov 20th, 2008 |
| Replies: 14 Views: 1,159 No.
The kernel is write-protected and you have to know the right magic to get past that.
Deliberately crashing the kernel isn't funny. It is downright dangerous. You can utterly destroy your... |
Forum: C++ Oct 6th, 2008 |
| Replies: 14 Views: 2,631 Sorry I've missed the last week (more or less).
To do fancy stuff with the console use the Curses library.
NCurses
Platform: POSIX
Where: http://www.gnu.org/software/ncurses/
Notes:
If you... |
Forum: C++ Oct 3rd, 2008 |
| Replies: 19 Views: 3,131 Sigh. You know, you really shouldn't be dinking with the screen at all. But if all you want is something to clear the screen in Win32 and POSIX, here are a couple of functions. Your teacher will know... |
Forum: C++ Oct 2nd, 2008 |
| Replies: 19 Views: 3,131 If this is just some homework problem, you could try one, then the other. Only one will work:
if (system( "clear" )) system( "cls" );
However, like ArkM said, better to do it the Right Way. |
Forum: C++ Oct 1st, 2008 |
| Replies: 19 Views: 3,131 The exact macro to test for depends on OS and compiler. Here is a handy reference for Pre-defined C/C++ Compiler Macros (http://predef.sourceforge.net/).
Unless you have been careful to predefine... |
Forum: C++ Oct 1st, 2008 |
| Replies: 4 Views: 434 I think the OP is interested in unbuffered input.
Win32: use <conio.h> stuff (me goes to wash my hands) or the Win32 Console Functions... |
Forum: C++ Sep 27th, 2008 |
| Replies: 7 Views: 653 You can't. The main() function is, by definition, the first function your program runs.
What difference does it make? Just call your function first thing in main:
int main()
{
... |
Forum: C++ Sep 24th, 2008 |
| Replies: 4 Views: 1,527 I think you'll have to go ask your professor for clarification. Sorry.
Oh, the bit position is indexed like an element of an array. So if your bits do represent strings (as in vector <string>... |
Forum: C++ Sep 24th, 2008 |
| Replies: 3 Views: 1,772 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: 872 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 24th, 2008 |
| Replies: 4 Views: 1,527 Your assignment is the kind of exactingly vague description I've come to expect from CS instructors. Do you have an exemplar of the input file? I will assume some things from here on:
A bit string... |
Forum: C++ Sep 23rd, 2008 |
| Replies: 1 Views: 485 You won't get any source... and you'll have to read your textbook, but think for a moment:
Should objects in shared memory be referencing things in the private memory of any process or thread?
... |