1,296 Posted Topics
Re: You define calculateRetailprice function but call calculateRetailPrice... C++ names are case-sensitive. A linker detects undefined reference to calculateRetailPrice... One letter price ;) | |
Re: If unlucky user accidentally types a wrong char your program comes to loop forever because subsequent cin inputs do nothing until [icode]cin.clear()[/icode] call. Always check input result, for example: [code=cplusplus] if (cin >> number) { // that's ok } else { // eof or not-a-number // Recovery? It's the other … | |
Re: No need in strchr, islower etc for latin letters only. [code=cplusplus] void CountUppers(std::istream& is) { if (!is) return; int cnt['Z'-'A'+1] = {0}; char c; while (is.get(c)) { if (c >= 'A' && c <= 'Z') ++cnt[c-'A']; } for (c = 'A'; c <= 'Z'; ++c) std::cout << c << '\t' … | |
Re: The root variable is not initialized (by 0) before dictionary loading. It has a garbage pointer value so the program are trying to insert nodes to nowhere (memory access violation or another troubles follows)... | |
Re: Because your Point::getXYZ does nothing (see x target instead of X, y instead of Y ... ;) ). | |
Re: Sorry, my post recalled... | |
Re: Better break one of two identical threads on this topic (this or there on C forum) ;)... I don't understand why you sent your C++ program to C forum?.. | |
Re: [url]http://www.dekart.com/products/encryption/private_disk/[/url] [url]http://electronicdesign.com/Articles/Index.cfm?AD=1&ArticleID=11266[/url] [url]http://www.secureyourflashdrive.com/[/url] [url]http://www.edgetechcorp.com/usb-flash-drives/guardian-secure-flash-drive.asp[/url] [url]http://www.radix-int.com/ksafe.php[/url] and much more... Flash memory self-destruction is a well-known optional feature of modern microcontollers. | |
Re: YOU should implement the stack ADT... Not at all ;) | |
Re: If VC++ Express distributive is too big for your channel, download and install much more compact Code::Blocks IDE with MinGW C++ compiler bundled: [url]http://www.codeblocks.org/[/url] | |
Re: 1. Let's suppose that you have a collision with word "table". The LinearProbing finds a new free location then places the word into this cell. But the next occurence of the word "table" gets collision again - and linearProbing finds the next free location, it does not check if the … | |
Re: Visual C++ editor shows text blocks deselected by conditional compilation directives as grayed (it's a stable state until you don't tread on #if-#else structure). Check #if-#endif balance and conditions in the new header version... | |
Re: Imagine your program user's reaction: Surprise! You waste a time because "the program tried to process a division by zero. Any results should not be trusted."... Obviously the best design solution is: DO NOTHING. Let the program catch divide by zero exception. It's not a problem of a low-lelel class. … | |
| |
Re: [icode]cin >> char_array[/icode] extracts only one word from input stream (upto whitespace occured - blank, tab or newline). The rest of typed string will been extracted with the next operator >> calls. For example if the user typed "Happy Guppy" then only Happy will be extracted from cin. To discard … | |
Re: [QUOTE=RohitSahni;732602]001 00002 0000003 00004 000005 6 000007 008009 ------------------------------------------------------------------------------------------------------ GBL UTG.L 0692861 DCGB 000000 0 205750 826UTG GBL UU.L 0646233 DCGB 000000 0 722501 -371UU. I have the above data line by line each and coloumn has fixed width then in those i want to assign 9 coloumns to variables … | |
Re: Well, you demonstrate absolutely senseless code (n is not initialized). And what's your question? | |
Re: [QUOTE=WaltP;731607]Why? It increments [B]i[/B], calls [ICODE]cube[/ICODE] with the new value, then returns the answer to [B]y[/B]. What's undefined about it? [B]i[/B] isn't modified twice.[/QUOTE] That's because cube is not a function name: it's a macros. We (not me, I never use macros) have: [code=c] # define cube(x)(x*x*x) int x = … | |
Re: Where was defined the type ptr? Why Node and node typenames occured in err messages? See also error C2244 description in MSDN... | |
Re: You are trying to build absolutely senseless, absurd class NoFather (remember The House That Jack Built... ;) ?): [code=cplusplus] class NoFather { ... private: NoFather DataNoFather; }; [/code] Well, we have an object of type NoFather which has a member of type NoFather which has a member of type NoFather... … | |
Re: 1. Correct function body, of course. Absolutely clear declaration: [code=cplusplus] void arrSelectSort(int arr[], int size); // the same as void arrSelectSort(int *arr, int size); [/code] 2. It seems you forgot to initialize total var... | |
Re: Look at this loop condition. If it's true it's true forever (not forever: until inevitable crash). [code=cplusplus] int i; for (i = 1; zahl != 0; i++) { // Congratulation! It's loop until all core was overwritten... arr[i] = zahl; //storage of given number } [/code] | |
Re: [code=cplusplus] void setDateMenu(Date myDate); [/code] You pass Date by value so set a new date to Date copy. The original object is intact. Pass by reference: [code=cplusplus] void setDateMenu(Date& myDate); [/code] Common error... I hope now you know that argument passed by value in C and C++ ;)... | |
Re: [QUOTE=jugnu;731908]When i use a variable type [B]double[/B] the value [B]e.g 345624.769123[/B] rounded to [B]345625[/B] but when i take [B]5 digits[/B] before decimal [B]i.e 34562.4769123[/B] then it shows [B]34562.5[/B] Please explain Why? Thanks[/QUOTE] Please explain where and when? | |
Re: Of course, it's possible, all viruses do that ;) . So you will have a lots of troubles with anti-virus protection on computers of your masterpiece unhappy users... | |
Re: [QUOTE=volscolts16;731981]What is a clock tick equal to in ctime??[/QUOTE] The time_t type is an implementation-defined arithmetic type capable of representing times. Use difftime function to get the difference between two times of type time_t in seconds as a double value: [code=c] #include <time.h> ... time_t t; time(&t); printf("time_t step %f … | |
Re: 1. It seems you don't implement any hash tables. A hash table is a container with insert, find and (may be) erase operations. But I can see only chimerical class - a mix of a fixed data file reading from unknown (for me) source, mysterious linearProbing method and final printing. … | |
Re: From the C++ Standard: [quote]The expression E1[E2] is identical (by definition) to *((E1)+(E2)).[/quote] Sometime pointer arithmetics code is evidently cleaner than "subsripted" one: [code=cplusplus] int countDigits(const char* str) { int n = 0; if (str) while (int c = *str++) if (c >= '0' && c <= '9') ++n; return … | |
Re: I can't crank an engine. Look at my car mark, please: it's a Crow Victoria. Do you have any idea? [url]http://www.daniweb.com/forums/thread78223.html[/url] | |
Re: The main criteria for the right solution of deserialization is: you must suspect that all data were crippled, edited by mad operators, data file name was changed, you get another, wrong file etc. Deserialization module must cope with all these situations (at least detect them)... Probably the best deserialization modules … | |
Re: I don't understand what for C# code appeares here. There are a lots of insertion (and others) sort C codes in INET. For example, that's one from the excellent tutorial [url]http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_sorting.aspx#insert[/url] [code=c] void jsw_insertion ( Str a[], int n ) { int i; for ( i = 1; i < … | |
Re: [QUOTE=Beginner+597;729364]hi everyone, I'm trying to write a program that calculates the the fourth sqrt() of an int ..., can someone help me thnxx[/QUOTE] And where is the product of your efforts? Remember classics: I'm trying to write a program to hop on the Moon... | |
Re: [QUOTE=Manutebecker;731254]Topic... just wondering if it would be friend or pointers in the main or something else...[/QUOTE] It depends. Can you describe some program cases where you need to share (polysemantic term) variables? | |
Re: It's not a problem to allocate 2D array or what else in C++. The problem is: how do you want access the allocated storage. You know that it's impossible to declare 2D array variable with run-time defined extents in C and C++. The most straightforward approach in C style but … | |
Re: Good idea! Free advice: don't waste a time to hire assembler programmers. Only 50 years ago programs of some million instructions were written without any assemblers in native machine codes. The new revolutionary OS kernel fits in some thousand instructions only. Obviously no need in assembler programmers to conquer this … | |
Re: Don't flatter yourself with the program of 1000 lines: it is a small program (max 2 days on implementation ;)). So the true problem is not a number of variables per se. It's not a common rule, but a well-designed function has 1-5 parameters. If it has 10 or more … | |
Re: Try this (add includes): [code=cplusplus] using std::flush; using std::cout; using std::endl; using std::cin; class Aircraft { public: Aircraft() { cout << "Aircraft is up!" << endl; } virtual ~Aircraft() {} virtual void doSomething() = 0; }; class Fighter: public Aircraft { public: ~Fighter() { cout << "Fighter landed." << endl; … | |
Re: [code=cplusplus] outfile<<name<<m1<<""<<m2<<""<<m3; [/code] Why empty string literals?.. Where is the last line terminator ('\n') ? Your text file is ill-formed... | |
Re: Both C and C++ provide for (implementation defined) asm declaration (builtin assembler code) so the formal answer is "Yes, you might do that". Can you - that's a question. It is better to bootstrap a new system from the scratch in C because the C runtime support is much more … | |
Re: I don't see any MiniDump class in your post (only MiniDumpHelper), but... Obviously SetUnhandledExceptionFilter wait a pointer to ordinar function (exception handler). But non-static member function is not an ordinar function and a pointer to it is not a pointer to ordinar function. Make it a static mamber (if possible): … | |
Re: By default class definition body starts with private zone. So you declare both operator= and operator+= as private members of Matrix (look again at you class Matrix). Well, you can't access them outside Matrix member functions and friends of the Matrix class. But your main function is not a friend … | |
Re: That's wrong expression statement: [code=cplusplus] *item--; [/code] It treated as *(item--) - see C++ operator priority table (or better write parentheses). So the program change a pointer only. For in/out parameters use references: [code=cplusplus] void Erase( int ar[], int& item, int7 Search) ... item--; // ok, decrement passed by reference … | |
Re: What is it "cursor pointer"? I know cursor:pointer pair in CSS, but it's the other story... | |
Re: [QUOTE=cikara21;730555][code=c++] //-------------------------------------- int A[2][2]={1,2,3,4}; //--overflow func(A); //-------------------------------------- int A[1][4]; A[0][0] = 1; A[0][1] = 2; A[0][3] = 3; A[0][4] = 4; //-------------------------------------- [/code][/QUOTE] What? Where is overflow? | |
Re: Read SDL tutorials carefully then correct misprints in you sources. Must be SDL_DisplayFormat, SDL_SetVideoMode etc... | |
Re: 1. Where is an object stored? All non-static members stored there, in the same place: [code=cplusplus] MyClass ImInStaticStorage; void where() { MyClass ImOnTheStack; MyClsss* pointToTheHeap = new MyClass; ... delete pointToTheHeap; } [/code] 2. Initially it points to nowhere if you don't initialize it (has unpredictable value). 3. What to … | |
Re: There are 250*2^24 possible bit patterns for 2-addr instructions. There are 2^32 bit patterns totally. So there are 2^32 - 250*2^24 free bit patterns for 1-addr instructions. Every 1-addr instruction occupies 2^12 bit patterns for all possible addresses. Therefore (2^32 - 259*2^24)/2^12 = 2^20 - 250*2^12 possible 1-add instruction. It's … | |
Re: The 1st printf in the original post ([icode]fprintf(txtFile, "%s", "\n");[/icode] ) should work too. The simplest way in C style is [icode]fputc('\n',txtFile)[/icode]. Apropos, [code=cplusplus] out_file << "\nHello, World"; out_file.close(); [/code] makes ill-formed text file where the last line is not terminated by line separator... | |
Re: 1. No language defined limits. Obviously, the language implementation (compiler) may declare such limit (don't worry, it's a huge number ;) . For example, VC++ 2008 eats this nightmare: [code=cplusplus] void*********************************************************************Ooh; [/code] 2. It's an error. Any object may been (identically) declared in some places but must have one and … | |
Re: Think: a preprocessor expands macros not only before the program run but before a compiler process sources! I can't just imagine what kind of useful macros you hope to invent... As usually, the best MxN code burst medicine is polymorhism. But now I can't suggest any solution on the too … |
The End.