1,118 Posted Topics
Re: You can't say: [code] int a[100], b[100]; a = b; [/code] That doesn't make sense. You can't change the value of [B]a[/B]. What would make sense is what you said: "i want the character array to be swapped with it." In other words, you want to exchange the [I]values[/I] in … | |
Re: > I was told to use pointers whenever possible In C++ you should avoid both. > i just don't know if a char pointer is possible. Did you try compiling your code above? Did it complain about a [inlinecode]char *[/inlinecode] ? You can make a pointer to [I]anything[/I]. You'd be … | |
Re: Between lines 51 and 52 you need to add [inlinecode]return EXIT_SUCCESS;[/inlinecode]. (If you start your code blocks with the name of the language you are using, you get line numbers: [[I][/I]code=C++[I][/I]].) Line 56: are you sure there is an argv[ 1 ]? Line 57: are you sure there is an … | |
Re: As long as you keep the sequence points intact and the two values are the same ordinal type then you can do it just fine: [inlinecode]a ^= b, b ^= a, a ^= b;[/inlinecode] Remember though, the result of this expression is the final value of [B]a[/B]. | |
Re: Heh, y'all missed my favorite really stupid language: Whitespace. [code]Say hello. [/code] Source: [URL="http://compsoc.dur.ac.uk/whitespace/examples.php"]whitespace examples[/URL]. BTW. That "Say Hello." thing at the top is just a comment... | |
Re: I don't know Lisp, but I do know Scheme. Write yourself a little recursive function that does the job. I would use an index into the string to keep the original string reference (instead of recursively operating on copies of substrings). When you run out of string, then you've found … | |
Re: I don't know where you got that code, but it is wholly ineffective. It uses the copy constructor whether you like it or not. Further, you left the return type off of the copy() function (so it wouldn't compile). If you declare it as: [inlinecode]A ©();[/inlinecode] then you'll wind-up with … | |
Re: You should be making better use of functions. For example, [B]convert[/B] would be better written as: [code=Pascal] function convert( c: char ): integer; begin convert := ord( c ) - ord( '0' ) end; [/code] And then used thus: [inlinecode]digit1 := convert( c );[/inlinecode] Also, you don't need to specify … | |
Re: I usually find that there is a good reason, but in this case I can't see any reason to have those temporary variables, as they are unused in any other way. Perhaps they are just a relic when the original author was debugging the routine... Also, this routine is amazingly … | |
Re: Do you mean [URL="http://en.wikipedia.org/wiki/Coprime"]coprimes[/URL]? Also, [URL="http://www.daniweb.com/forums/announcement8-2.html"]see this forum announcement[/URL]. | |
Re: What you need to do is find a useful reference. I like [URL="http://www.cppreference.com/"]cppreference.com[/URL], but it is rather curt. In C++, you can easily append strings and characters, so you might try something like: [code=C++] #include <iostream> #include <string> using namespace std; string spacesToTilde10( string s ) { string result; for … | |
Re: I almost missed this because your thread is marked 'solved'. That last thing is so full of errors I don't think you've spent much time reading over your textbook or class notes. It certainly won't compile, and most pascal compilers are pretty explicit about where and what errors you have, … | |
Re: Google "delphi sockets" for help. You'll have to implement a few server/client programs (the same program can be both) that allows you to communicate. There is no limit to [I]what[/I] you send over a connection (it looks much like a file stream when you use it). The trick is just … | |
Re: [URL="http://www.catb.org/retro/"]http://www.catb.org/retro/[/URL] "Other" languages are those without a specific forum here at DaniWeb. For example, Perl has its forum, but [URL="http://en.wikipedia.org/wiki/Scheme_%28programming_language%29"]Scheme[/URL] does not. Scheme stuff goes here. Likewise, something like [URL="http://en.wikipedia.org/wiki/Tcl"]Tcl[/URL] would go here. Both these are powerful languages in their own right, and used often enough today. (They aren't dead … | |
Re: Watch your condition flags. ADD modifies the flags register just as much as CMP does. So you only loop above if SI is not zero... Also, the last two lines never get called... Hope this helps. | |
Re: Macros aren't functions. When you use a macro the text of the macro is inserted verbatim into your code. Hence: [code=asm] print macro str .data x db str .code mov ax, seg x ... [/code] Gets used: [code=asm] print "Hello" print "world" [/code] and becomes: [code=asm] .data x db "Hello" … | |
Re: Er, this is the wrong place for such questions. This forum is for people progamming in C++. A CD usually needs to have some formatting done to it before writing. Perhaps your software is complaining that it hasn't been prepared to write audio data to it? | |
Re: If you wish this to be "portable" across at least Windows and Unix, you should make use of the curses library. You can get PDCurses which works on both systems, and a few others to boot. Most *nix systems come with ncurses (or at least curses) already installed and usable. … | |
Re: There are syntax and type errors throughout (maybe only a little dyslexia, perhaps?). For example: [inlinecode]printf("n\Thank you. You entered %s\n" PurchaseAmount);[/inlinecode] should read: [inlinecode]printf("\nThank you. You entered %d\n", PurchaseAmount);[/inlinecode] The main problem, though, is how you are handling types. Ah, I just previewed and I see [B]Salem[/B] has noted the … | |
Re: Just caught this... Your documentation must be damaged. There is no error in what I have. Where did you get your HLP files? Like I said, mine are a bit old, but I can send it to you if you like. | |
Re: Consult [URL="http://en.wikipedia.org/wiki/Booth%27s_algorithm"]WikiPedia[/URL]. It shows Booth's Algorithm in minute detail, and gives an example. Your code should have several subroutines: - one to display a binary number - one to do Booth's algorithm and return the product To display a binary number, just peel bits off of one end and put … | |
Re: Any time you find that you are repeating yourself, that is a good thing to turn into a loop. First, figure out what changes each time and what stays the same. The thing that changes is a variable. In your examples (done with [[I][/I]inlinecode[I][/I]] so that I can highlight something) … | |
Re: Listen to [B]Salem[/B]. C does not have a [I]vector[/I] anything. Nor does it have [I]generic[/I] anything. Those are both C++ constructs. | |
Re: > OK, so would eax, ax and al all be the same register/memory. Yes and no. Read on. > Can all three of those contain seperate values? Yes and no. Read on. AL is the [B]l[/B]ow-order byte of AX. AH is the [B]h[/B]igh-order byte of AX. Thus, AX is a … | |
Re: C library functions (like [B]printf[/B]) are typically prefixed with an underscore. In in the object library it is actually named [B]_printf[/B]. If you plan to use them you must also link the library itself. How to do this varies between assemblers / linkers. | |
Re: You have syntax problems. line #16: get rid of the word "double" --you are not declaring a new variable (you've already declared "yards" above). line #21: same kind of problem. Replace the word "double" with "meters". Move your yards() function (lines 5..28) above main() (to line 8). Rename the yards() … | |
Re: I've never programmed one myself, but your son could go through the [URL="http://en.wikibooks.org/wiki/TI-Basic"]TI-BASIC WikiBook[/URL]. It has examples and explanations galore, all in tutorial format. Good luck. | |
Re: The TListView is going to be really slow no matter what. However, there are a couple of things you can do to help. In your loop on line 9, you are starting at zero again. You don't need to check things already known not to be duplicates. Say instead: [inlinecode]for … | |
Re: You have two problems: 1. Add a break statement after you set i to zero: [code=C++] void validate_name(string &name)//validate_name for each student { int i; for(i=0;i<(name.length());i++) { while( !(isalpha(name[i])) && !(isspace(name[i])) ) { cout<<"Enter correct Name of student ,please:\n"; getline(cin,name); i=0; break; } } } [/code] 2. You need to … | |
Re: Have you looked at [URL="http://en.wikipedia.org/wiki/Assembly_language"]WikiPedia[/URL]? The next step is to get an assembler and start playing with it. | |
Re: Pascal is pretty smart about typecasting between real and integer. [code=Pascal] var i: integer; r: real; begin write( 'Enter an integer> ' ); readln( i ); write( 'Enter a float> ' ); readln( r ); writeln( 'You entered ', i, ' and ', r:5:2, '.' ); writeln( 'The sum is … | |
Re: >i mean is assembly have it own compiler . Essentially, yes. An [B][I]assembler[/I][/B] turns assembly code into machine code. >how can write assembly code . What system are you using? There are many different assemblers... | |
Re: The [B]system()[/B] call forks out to another process. So if you use it to change the directory, it affects the new process, not your program. | |
Re: You are on the right track. The only problem is that [B]char[/B] is a single character, not a whole list of them (or array of them). You probably want to use a pointer to an array of chars. Also, don't use %s in scanf() without qualifying it with a maximum … | |
Re: [B]ExplainThat[/B], this is a beginning programming school assignment. I really doubt the professor expects a recursive descent algorithm. Nor do I think he is permitted to redefine the shape of his input. All the professor wants is some basic string parsing. [B]joygqy[/B] Show us some code, and we'll help you. | |
Re: Windows was designed as a 'do everything' GUI, so you automatically get things like GetFontMetrics(). X11 is an entirely different beast. I don't know of any standard libraries for stuff you want. If you are willing to use QT then I highly recommend it. It is a powerful system for … | |
Re: Please, please, use [B][[I][/I]code[I][/I]][/B] blocks to post. Anything else leaves unreadable and difficult to cut/paste stuff. Also, this is the C++ forum, not C. You misunderstand a few basic concepts. [color=green][B]1[/B][/color] Anything with [B]const[/B] in front of it cannot be modified. You don't need it here, especially since you intend … | |
Re: That code won't help you with [URL="http://ptri1.tripod.com/"]Pascal's Triangle[/URL]. The computer is too stupid to help you do something. First figure out how to do it yourself, preferably with pencil and paper. Once you can do that, telling the computer how to do it is relatively easy. | |
Re: You can get rid of the line [inlinecode]Track(void);[/inlinecode] Move the following three lines: [inlinecode]string title;[/inlinecode] [inlinecode]string artist;[/inlinecode] [inlinecode]float duration;[/inlinecode] to between the two lines: [inlinecode]class Track {[/inlinecode] and [inlinecode]public:[/inlinecode] Since duration is in seconds, it should probably be [B]int[/B], not [B]float[/B]. Make your [B]time[/B] function match its prototype: [inlinecode]void Track::time()[/inlinecode] … | |
Re: What he is saying is that he wants you to read the file all at once instead of line by line or int by int or whatever. To do that, you have to know how big the file is in bytes in order to allocate the memory to store it … | |
Re: Always fix errors in the order they come. Line 81 is incorrect, so no variable named [B]recta[/B] is ever created, so when the compiler hits line 86 it complains about some structure variable you are using that doesn't exist. Try this instead: [inlinecode]Rect recta( 12.9, 13.4, 7.6 );[/inlinecode] Also, please … | |
Re: Your code and your input file don't match. I cannot tell which things you are trying to put where. Please try to explain what goes where and I will try to help. | |
Re: How did you know 2 was the mode of (1,2,2,3,4)? Figure out how you knew that then you can tell the computer how to know it. Does that make sense? I find that a piece of paper and a pencil help a lot. There are several ways I can think … | |
Re: Don't say [inlinecode]int main( void )[/inlinecode] either. The [B]main()[/B] function actually does take arguments... but if you don't want to deal with them use C++, not some bad C abomination: [inlinecode]int main()[/inlinecode] When in Rome, do as the romans. When using C++, use C++ I/O. Don't use getchar() (or any … | |
Re: I haven't looked over [I]all[/I] your code, but the [B]addAnimalToZoo()[/B] function looks fine to me. Polymorphism just means that you can derive from more than one class at a time. So, for example, you could make a SnakeHorse. | |
| |
Re: Have you looked at [URL="http://en.wikipedia.org/wiki/AVL_tree"]Wikipedia[/URL]? You really haven't given us much information to work with. "An array representation" can mean many, many different things. Post us the code you have so far and we'll help you fix it. Hope this helps. | |
Re: I haven't examined you algorithm very deeply, but somewhere in [B]changeBoard()[/B] you are accessing an element outside of the [B]board[/B] array. The error is recorded on the stack (the board is also stored on the stack), but only noticed when you try to return from [B]main()[/B]. | |
Re: You can split the string into tokens using the [B]stringstream[/B] class: [code=C++] #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; int main() { string s; stringstream ss; vector<string> v; cout << "Please enter a string to be separated by tab characters:" << endl; getline( cin, s ); … |
The End.