1,118 Posted Topics
Re: There are two easy ways: 1. Use [B]ShowMessage[/B]( char * ) This puts up a little dialogue box with your text and an OK button. It causes your application to pause until the user clicks OK. 2. If time is an issue, then call [B]AllocConsole[/B]() somewhere at the beginning of … | |
Re: Since this is the C++ forum, why don't you just dump sprintf() and use the standard streams? [code=C++] #include <string> #include <sstream> int main() { double b = 3.0000; std::string s; // convert double b to string s { std::ostringstream ss; ss << b; s = ss.str(); } // do … | |
Re: Hi Jennifer. You can use the [B]fill[/B] algorithm: [code=C++] #include <algorithm> #include <vector> int main() { std::vector<int> Numbers( 5000, 42 ); // 5,000 '42's. std::fill( Numbers.begin(), Numbers.end(), 0 // Turn them '42's into '0's ); } [/code] Now, if you really are using a vector of vectors (5000 * 5000 … | |
Re: A parameter is a temporary variable created by your routine. For example: [code=C++] void bigger_than_five( int number ) { result = (number > 5); } [/code] In this example, [B]number[/B] is the parameter (variable). [code=C++] int main() { if (bigger_than_five( 42 )) std::cout << "42 is bigger than 5\n"; else … | |
Re: Delphi IDEs aren't too fond of compiling units by themselves. What you need to do is: [list=1] [*]start Delphi [*]create a new project [*]from the main menu select Project->Add to Project [*]select the UIRT.pas file [*]from the main menu select Project->Build All [/list] You can then just get the UIRT.dcu … | |
Re: An EAbstractError occurs whenever an abstract method is called. For example: [code=Delphi] type // This is an abstract class tAbstract = class public procedure overrideMe; virtual; end; // This is also an abstract class tStillAbstract = class( tAbstract ) end; // However, this is not, since it provides methods // … | |
Re: [URL="http://www.newty.de/fpt/index.html"]The Function Pointer Tutorials[/URL]. Enjoy! | |
Re: I haven't looked through the QStat sources (and I don't plan to), but if it really is just a plain-vanilla command-line application then you only need to spawn it as a subprocess, and re-route its standard input and output to your application. Look through the docs for [URL="http://msdn2.microsoft.com/en-us/library/ms682425(VS.85).aspx"]CreateProcess[/URL]. Hope this … | |
Re: To determine which drives are available, their drive letters, and what kind of device they represent: [list] [*][inlinecode]DWORD [b]GetLogicalDrives[/b]()[/inlinecode] [*][inlinecode]DWORD [b]GetLogicalDriveStrings[/b]( DWORD nBufferLength, LPTSTR lpBuffer )[/inlinecode] [*][inlinecode]UINT [B]GetDriveType[/B]( LPCTSTR lpRootPathName )[/inlinecode] [/list] (Yes, the above is in C. Specify the [B]Windows[/B] unit in your using clause to use them. Delphi … | |
Re: The math library is just compiled code. It is in the ~lib/ directory. When you [inlinecode]#include <math.h>[/inlinecode] you are only telling the compiler what the things (functions) in the math library [I]look[/I] like. But that doesn't automatically link those functions into your program. You have to do it with the … | |
Re: Hey Sara, I don't mean to be too harsh, but at your current level this is [I]waaay[/I] over your head. It appears that you have been hacking at the above code for some time because it is a mess. If this is a school assignment it might be a good … | |
Re: A "batch" is a collection of things (data or jobs) to be dealt with by running a single program once. Hence, a batch processor is a program that will handle batches. A classic example is the old DOS command.com. Rather than type in a zillion commands each time you want … | |
Re: Miranda has a lot of similarities to Haskell. I can't say for sure that I can help you, but post your question and we'll see. Even if I can't, there are a lot of knowledgeable Haskell folks here that probably can. | |
Re: What do you mean by "upload"? If you just want to display the picture, you will have to get a JPEG decompression library (QBasic can interface with DLLs that do this), and you will need to switch to a GUI mode to display it. | |
Re: My thoughts exactly. [URL="http://angusj.com/resourcehacker/"]Resource Hacker[/URL] is a great little utility. You should be aware, however, that playing around with another program's resources is not always safe. Well-written programs will handle changes gracefully, but those that make assumptions about their resource data may fail. When you modify the bitmap, try to … | |
Re: There's nothing wrong with BC++Builder... What do you mean "make a TImage full screen"? Do you have an image you want to resize to your desktop? Or do you mean that you have a form and you want the image area to grow with the form when you maximize (like … | |
Re: As far as I understand it (having rarely ever used VC++), a [I]filter[/I] is MS's way of providing hooks into the application's main Window Procedure (which contains the top-level event loop) in order to process specific messages. [URL="http://www.codeproject.com/KB/miscctrl/MessgFiltersCallbackDeleg.aspx"]Here's a useful page I googled[/URL]. You will need to use [B]RegisterWindowMessage[/B] to … | |
Re: Yes to all. However: [list=1] [*]How do you mean? What colors and where? [*]Again, how do you mean? [*]Constants should be constant..., but a quirk of early Turbo Pascal dialects is retained as an option to make [I]typed constants[/I] pretty much the same thing as initialized variables. You should, in … ![]() | |
Re: Er, it doesn't go against Pascal's philosophy at all. The STL just does things from a different point of view. If you want to push and pop, it should be easy enough to write your own procedures to do that. Keep in mind, however, that Pascal doesn't (yet) have a … | |
Re: That timer event will not work like you expect. The Int10 is not guaranteed to have any specific value. While it may [I]appear[/I] to work sometimes (just as a fluke of how the stack works), it [I]will[/I] suddenly break and work differently. In either case, you should not [I]enable[/I] the … | |
Re: I'm not sure what exactly it is that you want. XRC is a file format used by wxWidgets programs to store the layout and arrangement of buttons and other widgets on a form. A program that uses wxWidgets can create a form using this resource format. The file is an … | |
Re: You are on the right track, but you need to think about what each segment should look like. For example, you could use 4 by 3 character grids for each segment, and the numbers as [code] _ _ _ _ _ _ _ | | | _| _| |_| |_ … | |
Re: Let the flame wars begin.... sigh. It doesn't really matter what language you choose to begin. You should be aware, however, that languages like lisp and scheme are [I]functional[/I], which is a different paradigm than [I]imperative[/I] languages like C++ and VB. You have to use different parts of your brain … | |
Re: The check should be to prevent the user of the function from passing in a string that is too long to fit in [inlinecode]st.n[][/inlinecode]. So: [code] /* Make sure the string is null-terminated */ memset( (void *)C.n, '\0', sizeof(C.n) ); /* Copy the string over, leaving room for null */ … | |
Re: If you google the fork() command you'll learn why. [code=C] t_pid pid; pid = fork(); if (pid > 0) { printf( "I am the parent. My child's PID is %u\n", pid ); } else if (pid == 0) { puts( "I am the child." ); } else { puts( "I … | |
Re: Whenever I want the user to enter an array of elements (and this is pretty common too) I always just ask for an extra ENTER at the end (a blank line). So the program might run something like this: [code] Please enter the elements of the array. Press ENTER after … | |
Re: [URL="http://www.cplusplus.com/forum/general/518/"]Link[/URL]. Check out my post at the bottom. (Sorry, I've got lazy fingers today.) | |
Re: Ah, ye olde rodent... Remember, a (basic) mouse only does two things: move and click (single click, that is). So, Windows and Delphi and whatever else have to make some basic assumptions about how the user will manipulate the mouse to distinguish things like drag and double-click from normal movement … | |
Re: Actually, you've done quite admirably. My score: 1768. A couple notes though: [list=1] [*]main returns int: [inlinecode]int main()[/inlinecode] [*]Don't use system("pause") and system("cls"). Here are some good replacements: [code=C++] void pause() { cout << "Press ENTER to continue..." << flush; cin.clear(); // (assume the user is playing interactively) cin.sync(); // … | |
Re: Use [URL="http://www.cppreference.com/stdstring/strcmp.html"]strcmp()[/URL] to compare the two strings. [inlinecode]if (strcmp( words[j], words[k] ) < 0) { swap j and k }[/inlinecode] The strcmp() function is nice because the operator you use (less-than, equal-to, or greater-than) is exactly the same as it would be if you could put it between the strings … | |
Re: Break it down into its constituent parts: [code] int yi = y - i; int val = row[ yi ]; if (val == x) goto return_false_part; if (val == x - i) goto return_false_part; if (val == x + i) goto return_false_part; [/code] Stick that in the loop, and add … | |
Re: You've got that backwards, bub. What you are saying is that you want your feature even though it wouldn't work or it would break on someone else's computer. Such a functionality doesn't cater to everyone. Just you. Since this is C++, whatever it is you are trying to do can … | |
Re: [B]ShellExecute[/B] will always open the file with the associated program --in your case, with Notepad. Take a look at [B]CreateProcess[/B] instead. This will allow you to specify the program to run and pass as argument the name of the file to open. I don't have the time at the moment, … | |
Re: You are clobbering a pointer or freeing memory too soon somewhere. Then, when the [B]delete[/B] operator tries to free the memory, you crash. Check that you aren't deleting something twice, or assigning a value to a pointer previously assigned a value with new. If you can't find it, post your … | |
Re: You need a loop. Like [B]repeat[/B]..[B]until[/B] or [B]while[/B]..[B]do[/B]. You can also check your answers using a [B]case[/B] statement. | |
Re: That [inlinecode]%*c[/inlinecode] is nonstandard. I suspect that you are trying to get rid of the newline. Instead, get rid of the newline with: [inlinecode]scanf( "%d\n", &my_int );[/inlinecode] Hope this helps. BTW, this is the C++ forum. | |
Re: Alt-F4 is used by the system to terminate an application. Users expect this. (Don't do things that users don't expect.) You might want to look at the OnClose and OnCanClose events if you just want to do cleanup before the application terminates or to prevent the application from terminating under … | |
Re: Hi [B]angelie[/B] and welcome to the forums. We won't give you code here, but we'll be glad to help you with your own code. There are two things you need to think about for this assignment: [list=1] [*]How to convert an ASCII digit character to a number. '0' to 0, … | |
Re: Show us what you've tried to do and we'll help you fix it. | |
Re: The correct answer is that the question is absurd. No programmer worth his salt would waste his company's time on some trivia like this. Yes, it is [I]possible[/I] to do an overlapped transpose and paste without using extra memory, but there is no [I]need[/I]. Can you really believe anyone to … | |
Re: A .COM file is a 16-bit image file. You'll need a 16-bit compiler and a 16-bit linker. I presume you are talking about an executable file, right? .COM as opposed to .EXE? | |
Re: [B]zhelih[/B] First off, don't just give people code. The whole point of homework is so that the student has to use his brain. Second off, it doesn't work, because the user can't input the first three numbers properly and it doesn't calculate the average. [B]sfurlow2[/B] Remember, the average is (sum … | |
Re: [URL="http://en.wikipedia.org/wiki/Fork_%28operating_system%29"]Link[/URL]. | |
Re: This isn't an IIRC, and no one here is going to respond very well to demands for help. You are very much closer. What you need to do now is two things. Take a look at the available C++ operators and use the correct ones. (The GPA problem is fine, … | |
Re: It is the input. This question has nothing to do with C++. It belongs in the Computer Science forum (which includes Theory of Computation). You might want to read up on [URL="http://en.wikipedia.org/wiki/NP_%28complexity%29"]NP complexity at Wikipedia[/URL]. | |
| |
Re: Alas, you've got a couple of serious errors... [COLOR="Red"][B]1) Get a string syscall[/B][/COLOR] When you use the systrap to get a string, the returned string has that NL character there at the end... So if I enter "1 2 3" the returned string is (in C parlance) [inlinecode]1 2 3\n[/inlinecode]. … | |
Re: For a simple, Turbo C text editor, I assume that your professor wants just a text-mode, <conio.h>, text editor? The only things you really need to worry about are: [list=1] [*]How is the file stored in memory? As a linked list of lines? Or buffered? (I recommend the first.) [*]What … | |
Re: The first problem this person had is that he did not comment his code very well. The second problem is that his comments don't match his code. The third (and most important) problem is that he did not write down what he was trying to do before doing anything. For … |
The End.