1,118 Posted Topics
Re: There's no way in a for loop, since the (first,last) is a special case. Also, watch your index bounds and maintain your result's aggregate value: [code=C++] double ClosedPolyPerimeter( double x[], double y[], int N ) { int i; double result = sqrt( sqr( x[N-1] -x[0] ) +sqr( y[N-1] -y[0] ) … | |
Re: Are you taking a course or just doing this on your own? You need to watch a few things. First, though, your strcopy should look like this: [code=MIPS] strcopy: lbu $t0,($a2) # load the char at $a2 sb $t0,($a3) # save the char at $a3 addi $a2,$a2,1 # next $a2 … | |
Re: A function is a function, whether it is a method or not. You must call it correctly, and in the right place: [code=C++] Odometer simulator; int number_of_miles_driven; cout << "Please enter the amount of miles driven : " << endl; cin >> number_of_miles_driven; simulator.input_miles(number_of_miles_driven); [/code] Notice how I changed the … | |
Re: Are you talking about [URL="http://en.wikipedia.org/wiki/Base64"]this kind of thing[/URL]? A number's representation is limited only by the number of digits used by the radix. We use [I]deci[/I]mal, meaning radix = 10: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. [I]Hexideci[/I]mal is radix 16: 0, 1, 2, 3, 4, 5, … | |
Re: Do try to compile your code before posting here. Once you fix it so that it compiles, post again. (an lvalue is the variable name to the [I]left[/I] of an equal sign). | |
Re: Just cast it the usual way: [code=C++] LRESULT CALLBACK MyWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { if (uMsg == WM_GETMINMAXINFO) { cout << "Max Window Size is (" << ((LPMINMAXINFO)lParam)->x << ", " << ((LPMINMAXINFO)lParam)->y << ")" << endl; } return DefWindowProc( hWnd, uMsg, wParam, lParam … | |
Re: OK, according to your problem description I have a few comments to help... But FIRST, please take the time to be careful about how you "format" your code. You've made some indentation errors (that is, because of the way you have indented your code you have made some errors!) [B][U]text … | |
Re: I know nothing about SunSparc assembly, but I think your problem is in mixing data types. When the user inputs a number, like 1230, that's four ASCII characters: 49, 50, 51, and 48. So, you need to decide what kind of numbers you intend to add: binary or ASCII? (I … | |
Re: I don't know anything about the CppUnit framework, but you should be able to compile just like any other. A makefile has a pretty simple layout. I'll assume that you are compiling a program named "quux" from the source files "quux.cpp" and "baz.cpp" and linking the library "bar". A makefile … | |
Re: What do you mean by "output window"? If you mean some TTY (like the console) then the answer is: yes, it is possible. If you mean some other thing then the answer is: maybe. Either way, you're going to have to be dinking around with things in an OS-specific way. … | |
Re: You don't have to be a professional. You only need to pay attention. So far you have not. When writing a post that contains code, place all your code in code blocks: [B][[I][/I]code=Pascal[I][/I]][/B] program fooey; begin writeln( 'fooey' ) end. [B][[I][/I]/code[I][/I]][/B] becomes: [code=Pascal] program fooey; begin writeln( 'fooey' ) end. … | |
Re: [B][[I][/I]code=Pascal[I][/I]][/B] [code=Pascal] writeln( h:0:1 ); [/code] [B][[I][/I]/code[I][/I]][/B] This prints a real value (h) with an indefinite number of whole digits (0) and only one fractional digit (1). Hope this helps. | |
Re: A 1D array is just a contiguous list of values. A 2D array is just a contiguous list of 1D arrays. I.e. [code] [0][1][2][3][4][5][6][7] :row 1 [8][9][A][B][C][D][E][F] :row 2 [0][1][2][3][4][5][6][7] :row 3 [0][1][2][3][4][5][6][7] :row 4 [0][1][2][3][4][5][6][7] :row 5 [0][1][2][3][4][5][6][7] :row 6 [0][1][2][3][4][5][6][7] :row 7 [/code] That's how we [I]think[/I] about … | |
Re: int : integer (int *) : pointer to integer (int *)& : reference to pointer to integer So, somewhere you have a pointer to an integer. [inlinecode]int *p;[/inlinecode] Your function wants to play with it. [inlinecode]findMax( ..., p );[/inlinecode] Now [B]p[/B] points to the largest integer in your array of … | |
Re: That's because you never actually uninstalled it. Press F1 and index "Installing Component Packages" to learn more. In a nutshell, there are two things you must watch for: the Delphi Library Path, and the available component list. Things on the component palette are chosen from the available component list, but … | |
Re: rc.exe is a program that comes with Visual Basic. If you are using Delphi/CodeGear you should look for brcc32.exe or something similar. If you are using Free Pascal or GNU Pascal, look for windres.exe. Hope this helps. | |
Re: Don't do anything. Just go to the next character. Remember, all you have to do is find matching (). It would help you an awful lot if you get out a piece of graph paper and draw yourself one of these equations, then figure out how to find and handle … | |
Re: You have still failed to stick your code in [B][[I][/I]code[I][/I]][/B] blocks, so that it is not a nightmare to read. May I ask what exactly it is you are doing that requires so many components and timers all on one form? Your program is going to work like an elephant … | |
Re: Same kind of answer as in your other thread. For each tCheckBox, set the [B]tag[/B] property to 1, 2, 3, etc. as appropriate. Then give them all an onClick event method like this: [code=Delphi] procedure tAnaForm.CheckBoxClick( sender: tObject ); begin if tCheckBox( sender ).checked then begin tLabel( AnaForm.findComponent( 'DIKEYAC' +intToStr( … | |
Re: At the risk of being repetitive for having mentioned this before, you may not have write access to your command line arguments. Moreover, you can't change their size. I think it is perfectly within reason to copy them into local character arrays: [code=C] int main( int argc, char *argv[] ) … | |
Re: When you post code, stick it in code blocks: [B][[I][/I]code=Pascal[I][/I]][/B] program Hello; begin writeln( 'Hello, world!' ) end. [B][[I][/I]/code[I][/I]][/B] becomes: [code=Pascal] program Hello; begin writeln( 'Hello, world!' ) end. [/code] This is the easiest to read and use. Click the little [color=blue]Toggle Plain Text[/color] link at the top to get … | |
Re: First, some thoughts: Your compiler lets you get away with it, but in C you should generally stick all variables before any code: [code=C] int i, n = 0, r; srand( time( NULL ) ); r = rand() %100 +1; [/code] Don't use (void) in front of printf(). (There's no … | |
Re: That's actually correct. A [B]char *[/B] points to [B]chars[/B], not [B]int[/B]s or anything else. So saying: [inlinecode]int i = *s;[/inlinecode] causes the computer to go get the (eight-bit) char at *s, then assign the value to the int i. If you want to get bigger numbers, you'll need to read … | |
Re: Sure, if you have enough room. For example, you can store two 8-bit values in a single 16-bit register. (By "string elements" do you mean "characters"?) A better question, though, is why do you want to do this? It doesn't sound safe. | |
Re: No one is going to give you code. Look in your textbook and at your class notes. There is an x86 opcode that does addition. | |
Re: > I am not sure if this is needed or not, but most CSV files have a header record, which is essentially the names of the columns separated by commas. If you are parsing an actual CSV file, you will need to take that into account also. That may be … | |
Re: Your reported errors don't have much to do with the code you are showing me (at least not as far as I can tell --please use [B][[I][/I]code[I][/I]][/B] blocks when posting). Are you using Delphi (a.k.a. CodeGear) or are you using FPC? If the former, then you should use the help … | |
Re: What you have written looks right. But just to make sure you got there correctly (which makes all the difference): 1. You added a button to your form and named it "ReverseOrderButton". 2. You either a) double-clicked the button on your form, or b) changed the object inspector to list … | |
Re: You are using the wrong function family. [URL="http://mkssoftware.com/docs/man3/execl.3.asp"]exec()[/URL] isn't supposed to return. Use one of the [URL="http://en.wikipedia.org/wiki/Spawn_(computer)"]spawn()[/URL] functions instead. Hope this helps. | |
Re: Yes, the regex is easy, but the code you use makes a difference. Just use [inlinecode](.*)have[/inlinecode]. That will match everything up-to and including the "have". The first "capture", or subexpression, is everything except the "have". | |
Re: Look in your documentation for TComponent.FindComponent. You can say something like: [code=Delphi] for i := 1 to 50 do tLabel(DisplayForm.findComponent('Label' +intToStr(i))).caption := tMemo(AnaForm.findComponent('Memo' +intToStr(i))).lines[0]; [/code] Untested! | |
Re: I think I see what you are trying to do. You have a list of students, where each student has a name and an ID. [code=C++] #include <iostream> #include <vector> using namespace std; // This is our student, who has a name and an ID struct student_t { string name; … | |
Re: There are no [I]procedures[/I] in scheme, only [I]functions.[/I] Whenever you say [B]define[/B], you are naming an expression that evaluates to something. Hence, follow along: [inlinecode](a-card 13 'spades)[/inlinecode] becomes [inlinecode](make-card 13 'spades)[/inlinecode] becomes [inlinecode](list 13 'spades)[/inlinecode] becomes [inlinecode]'(13 'spades)[/inlinecode] The [B]make-card[/B] and [B]a-card[/B] functions do the same thing: take a rank … | |
I'm always dinking with my PATH variable at the command prompt. But the supplied windows "path" command is (and has always been) pathetic. Well, after my latest episode of typing "path" and getting 6!!! lines of clutter I had had enough. So I wrote this little utility that lets me … | |
Re: I haven't played with it really, but offer only this observation: using floats exactly is playing with fire. And you're stepping on the gas with [inlinecode]payment/.01[/inlinecode]. If you must use floats, just say [inlinecode]payment*100[/inlinecode]. There's a nifty routine called [B]modf()[/B] that splits a float into its integer and fractional parts. … | |
Re: OK, here you go. (Don't use char arrays for strings.) [code=C++] #include <fstream> #include <iostream> #include <sstream> #include <string> using namespace std; string make_filename( int file_number ) { stringstream sfilename; sfilename << "Site_" << file_number << ".txt"; return sfilename.str(); } int main() { int Ns; string filename; for (Ns = … | |
Re: Your errors are not invincible, but they are all due to a very bad mixture of I/O (sorry). You'll need to trace your program (using a piece of paper and pencil) to see what is happening. Firstly, don't use output methods ([B]cout[/B], etc.) inside an overloaded input operator (>>). That … | |
Re: A TButton was not designed as a container component, so the IDE won't let you put labels in buttons. Why not just change the button's caption? If you must, however, see [URL="http://www.daniweb.com/forums/thread93077.html"]this thread[/URL]. Hope this helps. | |
Re: That won't work. Be careful how you initialize the stream. If I understand correctly, there are [I]two[/I] delimiters you need to worry about: the end of line ('\n') and the colon (':'[I][/I]), where the former is primary. So... [code=C++] #include <fstream> #include <iostream> #include <sstream> #include <string> using namespace std; … | |
Re: > how would i write a maximum number test function that will take any number of arguments and returns the greatest of them??? I think it would be very odd that your professor wants you to create a function that takes a variable number of arguments. Perhaps you should work … | |
Re: Sounds like you are asked to do something repetitively, so that suggests using a loop. Post some code and we'll help further. (You should be able to do this on your own.) | |
Re: What shell are you using. If it is bash or csh or somesuch, you need to use backquotes: [inlinecode]echo `expr 2+4`[/inlinecode] Hope this helps. | |
Re: You'll need to check your compiler's documentation. If you are using gcc, you can compile with the -S (that's a capital S) option to test some assembly code and look for yourself: [code=C] char foo( char c ) { return c +1; } int main() { return foo( 0 ); … | |
Re: You are going to have to play with the [B]crt[/B] unit. It has procedures and functions that will let you do things to the screen (clear it, move the cursor to a specific location, change colors, etc.) Good luck. | |
Re: You are both mixing between the pointer and the pointee. [inlinecode]CPoint foo;[/inlinecode] is an actual CPoint. It exists. [inlinecode]CPoint *foo;[/inlinecode] is a pointer to a CPoint. So far, no CPoint actually exists. [inlinecode]CPoint **foo;[/inlinecode] is a pointer to a pointer to a CPoint. So far, neither a "pointer to a … | |
Re: That program computes an approximation of PI by computing its own area. If you want to get more digits out of it, write a bigger program. [[URL="http://www.catb.org/~esr/jargon/html/O/Obfuscated-C-Contest.html"]1[/URL]] BTW. That one's been around for [I]years[/I]. It's one of the oldest entries in the [URL="http://www.ioccc.org/"]International Obfuscated C Code Contest[/URL]. | |
Re: It shouldn't work on XP either. You've declared "numb" as a [I]pointer[/I] to characters, but there aren't actually any characters being pointed at. Question: why are you using a char* anyway? Use the STL string class: [code=C++] #include <iostream> #include <string> using namespace std; int main() { string s; int … | |
Re: No. Do your own homework. If you want help along the way, post what it is that is giving you trouble and we'll help. | |
Re: No one here is going to give you something they had to pay for. Besides which, it's illegal. There are plenty of free programming resources on the web you can use just as well as anyone else. [URL="http://www.dmoz.org/Computers/Programming/Languages/"]Here's a good place to start[/URL]. | |
Re: Please listen to [B]WaltP[/B] and google it. [URL="http://en.wikipedia.org/wiki/Scanf#Format_string_specifications"]Here's what Wikipedia says[/URL]. You can find printf the same way. |
The End.