1,118 Posted Topics
Re: That's because the answer given you is not correct -- the [i]very first[/i] form auto-created in your DPR is the application's [i]main[/i] form -- which is not what you want. You still need to edit the DPR, but in a different way. If you google around "delphi spash screen" you'll … | |
Re: Your program needs to take the file name as argument. Example program: [code=C++] #include <fstream> #include <iostream> #include <limits> using namespace std; int main( int argc, char** argv ) { // Make sure the program has at least two arguments: // 1: the program's executable path // 2: the file … | |
Re: I'm actually surprised you posted something like this, as it is a dangerous function -- especially for newbies who don't really know what the consequences of using it are. Typically, a GUI should not be Sleeping/Delaying at all. If you [i]must[/i] pause for some reason, use one of the [URL="http://www.google.com/search?btnI=1&q=msdn+wait+functions"][b]Win32 … | |
Re: > For slow-witted reanimators: it's impossible in C and C++ to get a size of array argument by this array parameter only. Funny how there are all kinds of C and C++ libraries to do just that sort of thing. They are most popular for debugging and finding memory leaks. … | |
Re: I presume you are getting your error when lines 4 through 12 of Item.cpp are uncommented? You cannot just add methods to a class. You need to prototype them along with the class. [code=C++] class Item { public: Item(); ~Item(); void makeItem(int arrival, string dest); private: int arrivalTime; string destination; … | |
Re: Er, I don't know if modern versions of Delphi support PNG out of the box. (I use an older version.) If it doesn't, I recommend you get [URL="http://pngdelphi.sourceforge.net/"][b]PngDelphi[/b] by Gustavo Doud[/URL]. If it does, then you are doing something wrong. Show your code. | |
Re: Yes, use an [b]istringstream[/b]. [code=C++] string s = "John Doe M 36"; istringstream ss( s ); string name, given_name, surname; char sex; unsigned age; ss >> given_name >> surname >> sex >> age; name = given_name + " " + surname; [/code] Hope this helps. | |
Re: Your professor has actually given you a complete solution -- but his pseudocode is a bit off. Your function should take only one argument: [b]v[/b] - the value to convert to base 3. Everywhere you see "b" in his pseudocode you should replace that with "3" (because "b" is the … | |
Re: Hmm, without knowing anything at all about the OP's original purpose, this thread has become a hate-war over clearing the screen. It is not uncommon for old DOS programs to assume complete control of the console -- particularly in business environments. Catagorically stating that it is always/never acceptable to do … | |
Re: A [b]case[/b] statement only works on cardinal values (numbers), but you can perform a simple lookup to convert strings into an index into the list. Here's a little unit I wrote some years ago to do just that. [code=Delphi] unit uCaseStringOf; { Use strings in case statements Copyright (c) 2006 … | |
Re: You are trying to do too much work, especially for a large dataset. If you were to look at the list of hits on a piece of paper, how would you find the last one for each event? Yes, you would find the words "end of event" and look at … | |
Re: Listen to [b]Narue[/b]. You need a [b]bignum[/b] library. If you must fix it to exactly 20 bytes worth of data, then you can write your own simple class, or you can google around it to find some that others have written. The [URL="http://gmplib.org/"][b]GMP[/b][/URL] is pretty much industry standard. There are … | |
![]() | Re: You want to do something non-trivial. Why not just use [URL="http://www.irfanview.com/"][b]Irfanview[/b][/URL]? ![]() |
Re: The [URL="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller#Concepts"]Wikipedia article[/URL] explains it pretty well. The essential idea is that your application's parts should not need to know too much about each other. For example, let's consider a simple text editor. The "[B]model[/B]" represents the textual data and all the stuff you can do [i]to[/i] it, like load … | |
Re: What version of Delphi/Object Pascal are you using and with what compiler flags/directives? | |
Re: Is your program to assume that input values take the most restricted radix possible? (That is, given an input of "24" is it to assume octal?) Keep in mind that any string containing only the characters '0' and '1' is binary; any string containing only the characters '0'..'7' is octal; … | |
Re: Yes, you need to toggle to columnar mode. You'll have to poke around your keybindings to figure out how to do it. Using the "Classic" keybindings (the modified WordStar 3 ones) you can toggle using [icode]^O^C[/icode] (columnar) and [icode]^O^K[/icode] (normal block). I use D5 all the time -- I haven't … | |
Re: You should have yourself a little class that represents your data, and overload the extraction operator to handle it. Since I was really bored today, I wrote a program for you. Change the parts you need to match your assignment. Notice that there are several classes in use here. [list] … | |
Re: Are you talking about making your program provide a scripting language for plug-ins? | |
Re: For use on Windows platform only: [code=C++] #include <windows.h> ... void SetColors( unsigned fg, unsigned bg ) { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), ((bg & 0xF) << 4) + (fg & 0xF) ); } [/code] See [URL="http://www.google.com/search?btnI=1&q=msdn+console+functions"]Microsoft's Console Functions[/URL] for more. If you plan to write cross-platform code then I would … | |
Re: [quote]Why I can't compile without the using namespace std line?[/quote] You can, but you have to qualify things. Things like [b]cout[/b] and [b]string[/b] and [b]transform[/b]() are all defined in the [b]std[/b] namespace. If you don't [b]using namespace std[/b] (to tell the compiler that all the stuff in [b]std[/b] is also … | |
Re: Google works pretty good for me. [url]http://www.google.com/search?q=directsound+vs+tutorial[/url] Is this not what you are looking for? | |
Re: Do you mean that you are trying to handle something like when the user enters "flubbix" instead of a number? Make yourself a little function to get numbers from the user: [code=C++] #include <iostream> #include <string> #include <sstream> template <typename T> std::istream& get_number( std::istream& ins, T& x ) { // … | |
Re: If I'm using a Mac, how am I supposed to put a line in the file that contains a '\r' (without it being treated as an EOL)? | |
Re: Your constructor should look like this: [code=C++] Nation::Nation(string lName): name(lName), land(20), food(50), troops(15), gold(100), people(100), farmers(0), merchants(0), blacksmiths(0) { // Body left empty } [/code] The list of things are not functions (which is why the compiler is complaining, because you are using them like functions) but member fields. The … | |
Re: Inno Setup has pretty complete documentation, but it is not very easy to take in all at once. You need to open the section on "Pascal Scripting" and take a read through it. There are a variety of ways to handle what you wish to do, but you will probably … | |
Re: Microsoft function names are not very creative (which is a good thing). [URL="http://www.google.com/search?btnI=1&q=msdn+GetDC"][b]GetDC[/b]()[/URL] Hope this helps. | |
Re: No, the map sorts on the key. If you change the key then the sort order changes. You state that the key is the movie name for both maps, so the order should not be different. If you want a different sort criteria, then your map type should specify one … | |
![]() | Re: You will also need to explicitly instruct Windows to associate your port with a COM device. You can find instructions [URL="http://forums.virtualbox.org/viewtopic.php?f=6&t=26860"]here[/URL]. Finally, you would be aware that only "COM1" through "COM9" are specifiable like that. If you associate a port with a larger device number, you'll have to specify it … ![]() |
Re: Line 2 should declare [b]ch[/b] as an [b]int[/b]. | |
Re: You forgot give us your email so we can send it there after we have written your program. | |
Re: Yes. For some oddball reason it isn't in any of the Delphi docs that I've ever seen, but you can specify width and precision for floating point variables: [code=Delphi] var foo: real = 41.99; begin writeln( 'The answer is ', foo:0:1 ) end. [/code] Notice how it will automatically round … | |
Re: [URL="http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html"]Link[/URL]. | |
Re: You know, [B]cosmos22[/B], playing around with another person's computer really isn't funny. In fact, it is the kind of crap warez dorks and wannabes do. Why don't you do something that will be both appreciated [I]and[/I] cool? Like write a simple video game. Or write a cool screen saver you … | |
Re: There are differences in the [b]make[/b] 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 compiling in the non-POSIX (Windows native) environment, and the ~MSYS\...\bin\make.exe program when compiling under the MSYS POSIX environment. Hope … | |
Re: I think I see what you are doing. Your angle is too small (and in the wrong units). Consider, if you want a 5-pointed star: 360 /5 = 72, so each point is 72 degrees apart. BUT you want to draw a line to [B]every other[/B] point, so you will … | |
Re: Wait, you only want the [i]first[/i] line -- so what're all those loops for? [code=C++] ifstream musicCheck( "..." ); if (musicCheck.is_open()) { // The file is open, so read the very first line getline(musicCheck,songsUnlockedString); // Now that we've read it, we're done. No loops needed. } musicCheck.close(); [/code] Hope this … | |
Re: Your operators should have the following prototypes: [inlinecode]Alsation operator + ( const Alsation& x );[/inlinecode] [inlinecode]Alsation& operator = ( const Alsation& y );[/inlinecode] Hope this helps. | |
Re: Hint: have a [b]double[/b] variable that holds the previous value in the array, and a variable for the current value of the array. Subtract the current from the previous. Also, remember that 2 minus 9 is -7, but the difference is an absolute number: 7. (You'll need to use [URL="http://linux.die.net/man/3/fabs"][b]fabs[/b]()[/URL].) … | |
Re: Use a [b]std[/b]::[b]stringstream[/b]: [code=C++] void Set_Actors(ifstream &fin){ string s; getline(fin, s); istringstream ss(s); for (unsigned n=0; getline(ss, Actors[n], ','); n++){ ss >> ws; } } [/code] Notice how I use [inlinecode]>> ws[/inlinecode] instead of [inlinecode]ignore(...)[/inlinecode]... it is more robust that way. Hope this helps. | |
Re: You need to write a lambda (you can either name one or use [b]letrec[/b]) to compare two colors (proper lists of three numeric elements). Once done that you can sort your colors any of the usual ways. Remember, you can build your list by adding elements either at the front … | |
Re: I don't like the current direction, though. I think embarcadero screwed up on a few things... Alas. | |
Re: It is probably because you've got a [inlinecode]cin >> foo;[/inlinecode] somewhere else in your program. You can't blithely mix >> and getline() input, because [b]the user will [i]always[/i] press ENTER at the end of every input[/b]. Your inputs, then, should look like this: [code=C++] // get something with >> int … | |
Re: Make your [b]menuFuntion[/b]() return whether or not the user elects to continue. So main would look something like: [code=C++] bool menuFunction(); int main() { while (menuFunction()) ; cout << "Goodbye.\n"; return 0; } [/code] Your [b]exit[/b]() function is a dangerous name conflict, especially just to write something before quitting. Hence, … | |
Re: You are mis-naming things, and that is not helping. Also, you are using a list composed by (pointer to (pointer to car)). Why not just use a list composed by (pointer to car)? That is, you are using an array of (pointer to car) instead of just an array of … | |
Re: ...also, you need to check to see if the number would be less than zero [i]after[/i] subtracting, not before: [inlinecode]num = (num >= subtrahend) ? (num - subtrahend) : 0;[/inlinecode] If your number is signed, you can just use the proper <algorithm> [inlinecode]num = max( 0, num - subtrahend );[/inlinecode] … | |
Re: A stack is just a "last-in, first-out" (or LIFO) structure. You can make one with an array: [code=C++] const unsigned STACK_SIZE = 50; unsigned stack_used = 0; int stack[ STACK_SIZE ]; [/code] To add an item, just stick it at the end of the stack and bump the number of … | |
Re: I'm not sure I understand your homework assignment. You have three halt states: G (good), neutral, and B (bad). However, your NFA only accepts for G and neutral. Hence, you really only have two halt states: G (good) and neutral. This is all the information you have given me. With … | |
Re: Check out the [B][URL="http://www.cplusplus.com/reference/clibrary/csetjmp/"]<csetjmp>[/URL][/B] library. Don't mess with the stack. Otherwise you invite death. |
The End.