1,118 Posted Topics
Re: That's because on line 22 you abnormally terminate the program. Don't do that. | |
Re: You could always initialize the board to be filled with [i]invalid[/i] values (like -1) which is excluded from all comparisons. Your modulus idea is good. | |
Re: This page on Wikipedia ([URL="http://en.wikipedia.org/wiki/MIPS_architecture#MIPS_Assembly_Language"]MIPS Architecture: Assembly Language[/URL]) is an excellent resource to begin with. Another useful resource is the [URL="http://chortle.ccsu.edu/AssemblyTutorial/index.html#part8"]Programmed Introduction to MIPS Assembly Language[/URL]. It has a couple chapters on Floating Point Data replete with important points and simple examples. You can also search the forum for additional … | |
Re: On Windows, check out [B]QueryPerformanceCounter[/B]() and [B]QueryPerformanceFrequency[/B](). | |
Re: That's because you are actually creating two different [i]types[/i] of structure. In C and C++, arrays are something of a mixed bag. When you declare [inlinecode][B][COLOR="Green"]int[/COLOR][/B] a[ [COLOR="Red"]10[/COLOR] ][ [COLOR="Red"]5[/COLOR] ];[/inlinecode] What is actually allocated is [inlinecode][B][COLOR="Green"]int[/COLOR][/B] a[ [COLOR="Red"]10[/COLOR] * [COLOR="Red"]5[/COLOR] ];[/inlinecode] And when you access: [inlinecode]a[ [COLOR="Red"]4[/COLOR] ][ [COLOR="Green"]3[/COLOR] … | |
Re: As this thread is more than two years old, I don't think the OP is too interested in the answer anymore... :X | |
Re: I think you are kind of close, but you need to be careful about a couple of things. The first problem is that the variable [b]lookahead[/b] is local to [B]lexan[/B](), so your compiler should be complaining about lines 11, 12, 14, 23, 27, etc. The second problem is that you … | |
Re: The problem is that an array declared as: [inlinecode][B][COLOR="Green"]int[/COLOR][/B] a[ [COLOR="Red"]42[/COLOR] ][ [COLOR="Red"]17[/COLOR] ];[/inlinecode] is not the same as [inlinecode][B][COLOR="Green"]int[/COLOR][/B] *a[ [COLOR="Red"]42[/COLOR] ];[/inlinecode] The first is a 2D array of 714 (42 x 17) [B]int[/B]s. The second is a 1D array of 42 [B]pointers to int[/B]. The [B]c_function[/B]() is looking … | |
Re: All you need is an array or [B]vector[/B] of items, say '[B]t_top_score[/B]', which you read from file, modify, then write back to file. [code=C++] struct t_top_score { string name; int score; friend ostream& operator << ( ostream& outs, const t_top_score& top_score ); friend istream& operator >> ( istream& ins, t_top_score& … | |
Re: Numbers and strings are two different kinds of thing. You'll need to convert between them. Use [B]strtol[/B]() or [B]strtoul[/B]() to turn your string into a number ([B]long[/B] or [B]unsigned long[/B] respectively). Hope this helps. | |
Re: Wow, I'm really surprised to see [B]AD[/B] so boiled up over something like [B]goto[/B]. (I thought you were cool man.... *sniff* --- heh heh heh) Actually, you'll notice that [b]goto[/b] still exists in many modern languages. Why? Because it has its place. A rare one, but still useful. All the … | |
Re: You've got the right idea, except that you can't name your constructor or destructor something different than the name of the class. [B]TFP.h[/B] either [code=C++] class ToonFillPrint { public: ToonFillPrint(); // constructor ~ToonFillPrint(); // destructor }; [/code] or [code=C++] class TFP { public: TFP(); // constructor ~TFP(); // destructor }; … | |
Re: The suggestion offered you does exactly what you want. [code] int i = 3; string s = "pineapple"; cout << s << i; [/code] produces [quote]pineapple3[/quote] | |
Re: In reality, almost all hardware does both I and O with the system. The difference is in how the device is integrated into the system. A keyboard is typically (and AFAIK, always) treated as an input device, so programs that interact with it through the keyboard device driver can only … | |
Re: In the most platform-neutral way, use [b]system[/b](). For Windows, you can also use [b]CreateProcess[/b]() or the [b]ExecProgram[/b]() macro. To save things to the desktop, you first have to know where it is. Use [url="http://msdn.microsoft.com/en-us/library/bb762203(VS.85).aspx"]SHGetSpecialFolderlocation[/url] Hope this helps. | |
Re: @[b]shankhs[/b] You've got the right idea (for one way of doing it). You might as well give the last argument a default value: [inlinecode]bool rec(string a,string b,int i=0)[/inlinecode] You also need to watch your termination condition. If [b]a[/b] and [b]b[/b] have different lengths you may get an access violation. [edit] … | |
Re: We won't do your homework or reply offline. However, I can help you think through your problem. A number is a number is a number is a number, no matter how it is represented for us humans. 10 dec == A hex == 12 oct == 1010 bin. The only … | |
Re: There are numerous types of [B][I]memory[/I][/B]. There is external memory (stuff stored elsewhere like on disk or over a network or the like). Everything else I'll say here relates to internal memory: memory your computer has direct access to. There is RAM -- Random Access Memory, which is accessed via … | |
Re: Is this homework or workwork? What is the application? Semantics is a pretty broad field. In a very [i]small[/i] domain, you can track semantics, but if the programs are very disparate in design then you are going to have a pretty tough time. I suggest you look into [i]lexical analysis[/i]. … | |
Re: Your loop encompasses both the menu and the selector, as: [code] do { display_menu(); select_option(); while (!done); [/code] So if the option is bad, the menu gets displayed again anyway. What you'd probably like instead is something that catches itself. You can do it several ways, but another loop will … | |
Re: Standard containers don't actually free memory they use (AFAIK). You have to replace them. One way to do that is to swap it with itself: [inlinecode]v1.swap( v1 );[/inlinecode] I am shocked, however, that a 1.5 MB datafile uses 20MB memory. How exactly are you storing the data from the file? | |
| |
Re: You're getting a stack overflow on windows? Are you on Windows 98 or something? In any case, make sure you don't multiply too large of a number. It costs a lot more than you think in stack space to call a function, so it adds up fast. The reason you … | |
Re: Hmm, sorry. I thought I responded to this already. You'll have to set the [b]DefaultDrawing[/b] property to [b]false[/b], and provide a method for the [b]OnDrawCell[/b] event. Here's an example I googled. [url]http://bcbjournal.com/bcbcaq/index.php?loc=grids&caq=48[/url] (It is in BC++, but all the essentials are the same, so you shouldn't have any trouble reading … | |
Re: I'm sorry but I don't see the logic error here. Did you actually cut-and-paste this code in or did you eyeball-to-fingers type it in? (BTW. Please use [[b][/b]code[b][/b]=Delphi] ... [[B][/B]/[B][/B]code[B][/B]] tags.) A couple of observations: 1. [B]ComputerWord[/B] should be filled with uppercase letters, but you are using a lowercase 'a' … | |
Re: Of course, once you get the whole line, you'll want to parse it using a stringstream and getline() again... [code=C++] #include <algorithm> #include <iostream> #include <sstream> #include <string> using namespace std; char morse_decode( string letter ) { ... } bool is_multiple_spaces( char a, char b ) { return (a == … | |
Re: [URL="http://www.unixwiz.net/techtips/remap-pipe-fds.html"]Link[/URL]. Enjoy! | |
Re: IMO, interfacing with the user is one of those things that needs to be absolutely bullet-proof. There are two things to keep in mind here: 1. How does the [i]user[/i] expect to interact with your program. 2. How does your program react to insane responses. Answer 1: For console applications, … | |
Re: The problem is with types and initializer syntax. Make sure that an empty OPTIONS is [inlinecode]{ string(), vector<string>(), 0 }[/inlinecode] NULL is not a valid vector<>. Hope this helps. | |
Re: Heh heh heh.... You're going to love this: [code=C++] #include <algorithm> #include <fstream> #include <iostream> #include <iterator> #include <string> using namespace std; int main() { string filename; cout << "Enter the numbers filename> "; getline( cin, filename ); ifstream file( filename.c_str() ); if (!file) { cout << "Invalid filename.\n"; return … | |
Re: You will have to keep track of whether or not the user has supplied a filename yet. If not, display the save dialog. If he has, then don't bother displaying the dialog and just save the file. Essentially, your OnClick handler for the button should work like this: [code] if … | |
Re: [URL="http://en.wikipedia.org/wiki/Dijkstra's_algorithm"]Nonsense.[/URL] | |
Re: Hi! The following is also a very illuminating document. [URL="http://david.tribble.com/text/cdiffs.htm"]Incompatibilities Between ISO C and ISO C++[/URL] | |
Re: You know that you can [b]getline[/b]() with any character as delimiter, so why not use that to test for a potential separator sequence? [code=C++] #include <iostream> #include <string> #include <vector> using namespace std; vector<string> read_lines( istream&ins, const string& separator ) { vector<string> lines; string line; char head = separator[ 0 … | |
Re: You need to be working with floats on the right-hand side to get floating-point division. Right now you are doing integer divisions. [inlinecode]s -= 1.0/(i*i);[/inlinecode] This one gets everyone at least once a year. Hope this helps. | |
Re: Or rather: [code=C++] #include <limits> ... int main() { ... cout << "Press Enter to continue..."; cin.ignore( numeric_limits<streamsize>::max(), '\n' ); return 0; } [/code] | |
Re: [code=C++] template<typename T, typename U> void print_first_five( map<T,U> m ) { for (int i = 0; i < (m.size() >= 5) ? 5 : m.size(); i++) cout << m[i].second; } [/code] Hope this helps. | |
Re: Treat them as any other stream. So yes, watch for EOF. Hope this helps. | |
Re: It is because you are trying to pass a temporary object to the function. Temps are const. Therefore your function header should be: [inlinecode]void CreateCostGrid(const vector<ScanPoint> &Data, int whichcol, vector<LiDARScan> &LiDARGrid);[/inlinecode] If you want to modify the data, then your [b]getColumn[/b]() function must return a non-const reference. [inlinecode]vector<ScanPoint>& getColumn(...);[/inlinecode] Hope … | |
Re: Google "msdn FindFirstFile", FindNextFile, FindClose. For the path, just put the floppy's drive letter first, like "A:\*". | |
Re: You are screwing-up your [b]gcount[/b]() by using [b]ignore[/b](). Get the count first, then ignore. Hope this helps. | |
Re: Get rid of that [inlinecode]-c[/inlinecode] and try again. Linux only executes ELFs, not OBJs. | |
Re: Please tell us: [list=1] [*]Exactly what OS you are programming for [*]Exactly what GUI package you are progamming for [*]Might as well tell use your compiler, too [/list] | |
Re: Or you could read one line at a time (or even the whole file) and use standard algorithms to remove digits: [code=C++] #include <algorithm> // remove_if() #include <cctype> // isdigit() #include <functional> // ptr_fun<> #include <string> ... string remove_digits( const string& s ) { string result( s ); result.erase( remove_if( … | |
Re: Are you using a global or local hook? If global, it is possible that IE installs a global hook on "https://" pages that blocks the rest of the hook chain. The only way around that would be to install your hook after IE opens the https page, and I don't … | |
Re: That won't help to reduce/simplify fractions so much as using the Greatest Common Divisor. Here it is with the Euclidean algorithm, unrolled one iteration. [code=C++] int GCD( int a, int b ) { while (true) { a = a % b; if (a == 0) return b; b = b … | |
Re: [i]Display[/i] and UI are linked. Sorting (an underlying algorithm) is not. The best CUIs provide maximum data display and minimum query display. For example, your program may run something like this (bold represents user input): [code] % [b]a.out[/b] Crush Yer Bones's College Project Mr. Teacher Algorithms, Spring 2008 Enter 'help' … | |
Re: You should have gotten a runtime exception for trying it... Anyway, Windows apps don't have consoles by default. At the beginning of your program you'll have to [inlinecode]AllocConsole();[/inlinecode] then... you'll have to hook the standard streams up to the console: [url]http://www.halcyon.com/~ast/dload/guicon.htm[/url] (yoinks!) Its easier than it looks. Have fun. | |
Re: You might also benefit from reading through [URL="http://www.newty.de/fpt/index.html"]the Function Pointer Tutorials[/URL]. | |
Re: Don't do this: [inlinecode]char recordd[sizeof(record)] [COLOR="Red"][b]= {0}[/b][/COLOR];[/inlinecode] It isn't doing what you think it is. As another hint, you should compile using the [b]-Wall[/b] option. I did and it told me, right off the bat without having to look at your code: [list] [*]You are missing a header (since the … |
The End.