1,296 Posted Topics
Re: That's it: [code] v2 = Data[ i+1 ][ 9 ]; [/code] Obvious subscript error [b]i+1[/b] on the last element ;) Next time use code tag with the language specifier: [noparse][code=cplusplus] source [/code][/noparse] DaniWeb engine shows source line numbers in that case... | |
Re: Ooh... You have incremented currentSize just before the search/accept/reject loop so the last appointment index is [b]currenSize-1[/b] in the loop!.. | |
Re: [QUOTE=kelechi96;855301]Ok so I want to create some code which can generate a random number from a 1. Music file 2. A microphone PLEASE is their anyway i can do this[/QUOTE] It's possible but you need non-trivial theory and lots of experiments. As usually results of these works were a very … | |
Re: Alas, it's an absolutely incorrect algorithm. Look at your select condition: [code=cplusplus] if (check_array[t] == array_element) // if match is found { flag = 1; break; } [/code] In other words you make selection if and only if you have selected the element already! Quite the contrary, make selection if … | |
Re: Don't waste a time. Better try to invent you own algorithm then try to implement it then come back ;) | |
Re: That's a nightmare... Is it a program in C? No, of course (see reinterpret_cast). But if it's a program in C++, where is operators new instead absolutely inadequate mallocs?! I can't understand why you allocate memory then overwrite the pointer obtained from malloc in the next statement (and you? )... … | |
Re: I think no need in additional storage and other complicated stuff. A brutal force solution has complexity O(n*n): [code=cplusplus] template <typename T> // O(n*n) int modeIndex(const T* a, int n) { // Returns the 1st mode candidate index or -1 if no values. int midx = -1; if (a && … | |
Re: My 2 cents in this dogfight... It seems there is a simple answer to the OP question: [code=c++] delete this; // it's not a common case but it works [/code] It's impossible to invent a reasonable interpretation for this evidently useful and sensible construct if [icode]delete pointer[/icode] produces a side … | |
Re: [QUOTE=tux4life;854177]Strange the following is working: [ICODE]final += hex_string;[/ICODE] As far as I know [ICODE]hex_string[/ICODE] is a pointer and [ICODE]final[/ICODE] is a string, but I don't know whether the [ICODE]+ operator[/ICODE] is overloaded for data of type [ICODE]char*[/ICODE] ...[/QUOTE] Of course, it's impossible to overload operator + for char* type ;) … | |
Re: You don't initialize cmd_array at all (reread you source) then you are trying to "strcpy" uninitialized cmd_array[4] pointer. Where is cmd_array_W declaration? Where is count value test (cout > 4)? Are you sure that inbuf contains more than 4 tokens? Why? ... | |
Re: [QUOTE=yara naser;856114]hi: please help me to find the code that convert nfa to dfa by using c++ and please send it to my email [email removed] thank you very much please help me now.....:icon_neutral:[/QUOTE] [url]http://en.wikipedia.org/wiki/Nondeterministic_finite_state_machine[/url] May be you prefer if I will send you the solution via an express messenger? … | |
Re: 1. Probably you have never seen that... const var [b]with constant-expression initializator[/b]. 2. Your inData stream is in eof state after findRows call. It can't get you anything in readData. Do close then reopen or reinitialize the stream: [code=cplusplus] inData.clear(); inData.seekg(0,ios_base::beg); [/code] Now you may bump into another Great C++ … | |
Re: Keep it simpler: [code=cplusplus] return abs(getDayNumber(date1) - getDayNumber(date2)); [/code] | |
Re: [QUOTE=Ancient Dragon;855416]There is no such concept as "dereferencing and operator". Operators are like <, >, <=, /, +, etc. You probably mean dereferencing a pointer. [code] int n = 123; int* p = &n; *p = 0; // dereferencing a pointer [/code][/QUOTE] It's interesting that there is a page in … | |
Re: ~0.5 years ago, not so far, far away (on DaniWeb forum): [url]http://www.daniweb.com/forums/thread148080.html[/url] ;) | |
Re: Consider this C++ (correct) module: [code=c++] #include <iostream> void f() { ... balanced text ... std::cout << "} missed\n"; ... balanced text ... /// @todo ( counter! } [/code] How about balances of {} and () without some kind of (simplified) C++ scanner (lexical analyzer)?.. | |
Re: [QUOTE=William Hemsworth;855257]Salem also made a good point in my reputation, I miss him actually being able to post :icon_rolleyes: I don't use C very often, and very rarely use [B]printf[/B], but as he pointed out, you can do something like this instead:[CODE=CPLUSPLUS]#include <stdio.h> int main() { printf("%08s\n", "18"); printf("%08s\n", "3048"); … | |
Re: Can you explain: why quotes in the prompt message? Did you want to delude a user? If he/she types the name with quotes (by example) you can't use it as a file path in open function... | |
Re: >AND it with a bitmask 0x00FF to get the lower 16 bits... It's one-byte mask... Where are 16 bits?.. >If bit 15 == 1, then OR all ones into bits 16-31 using the bitmask 0xFF00... It's one-byte mask too... ? | |
Re: >To calculate pi it might be useful to have a high-precision float available where you can store your calculation in... To calculate pi it might be useful to have a computer with regualar IEEE floating point arithmetics (type double in C++), good algorithms and basic knowledges in computational mathematics. ;) | |
Re: Please, make this terrible code refactoring as soon as possible: 1. Stop using of global variables immediately. Pass appointment list array, its capacity (max size) and a reference to the current free index as addAppointmentRecords arguments. 2. Use operator == for appdate structures instead of these awful member by member … | |
Re: Another defects: 1. the default (the 1st) ctor does not initialize dummy and thename members. 2. the 2nd ctor does not initialize dummy member. It saves a simple pointer to the 2nd arg (especially dangerous) 3. the 3rd ctor does not initialize name member (especially dangerous case). Can't get literal … | |
Re: [code=cplusplus] void name() { std::cout << "It's me, Xamas\n"; } inline void anothername() { name(); } void ((*yetanothername)()) = name; void tryThis() { name(); anothername(); yetanothername(); } [/code] ;) | |
Re: The only special function you needed is [b]main[/b]. It's C++, why memset, atoi and other C stuff? | |
Re: [code=cplusplus] ofile.open(file.c_str()); ... ofile.close(); // function call! [/code] In the current C++ Standard [icode]fstream::open[/icode] member function wants [icode]const char*[/icode] argument only, not [icode]const std::string&[/icode]. | |
Re: ...and try to avoid comments like this [code=cplusplus] a += 1; // add 1 to a [/code] It's not old good Cobol language and your program readers are not (all) idiots (I hope ;))... | |
Re: [QUOTE=drjay1627;854218][code]int c, s; sscanf ( inBuf, " %d %d", &c, &s ); [/code] I wanna check if c and s are actually int. suppose if you enter a letter rather than a number, how do i check? drjay[/QUOTE] Fortunately, it's so simple: [code=cplusplus] if (sscanf(....) == 2) { // that's … | |
Re: Feel the difference: the 1st loop is correct, the 2nd one is wrong. A stream eof state detected only after some input operation. Suppose the file contains a single line: 1. eof() returns false. 2. getline gets a line (no eof state detected now) 3. push a line, OK 3. … | |
Re: Regrettably the OP question (and all the thread ;)) is a product of a misunderstanding of an array semantics in C++ (and C). If we have an array which is defined as [icode]int x[100] = {1,0,3};[/icode] then we have an array of [b]100[/b] (one hundred) elements. The leading three elements … | |
Re: See references in [url]http://en.wikipedia.org/wiki/Kd-tree#Removing_elements[/url] | |
Re: About Poisson distribution theory see [url]http://en.wikipedia.org/wiki/Poisson_distribution[/url] | |
Re: [code=c] while("sMessage[x]"){ [/code] Why quotes?! ;) It's a loop forever: while (pointer to string literal != 0). It never is null... | |
Re: [code=cplusplus] myfile.open(filename,ios::app); [/code] | |
Re: [QUOTE=Siaa;853094]hello every1..... i need ur help........im looking 4 a program which uploads a picture of the galaxy....then detects and counts the total number of stars in it.......can any 1 help me with this........ its really urgent.......its my assignment n i need to submitt it very soon........ waiting 4 ur replies........[/QUOTE] … | |
Re: May be (I'm not sure) the problem is: [quote]The variant types VT_DISPATCH, VT_UNKNOWN, and VT_BSTR are pointers, and do not require another level of indirection.[/quote] If the 3rd argument of SafeArrayPutElement call has BSTR type, no need in an address operator in the call (?)... | |
Re: 1. I'm sure that you misunderstand your assignment specifications. It's an absolutely senseless FP data type with a very long exponent and so reduced mantissa. 2. Why string? And even if so, why bitwise operators? | |
Re: Try to explain this object model sceleton improvisation: ;) [code=cplusplus] class Packet { public: ... bool parseLine(const char* pline); bool parseLine(const string& line) { return parseLine(line.c_str()); } int getId() const { return messageId; } int getNumber() const { return myNumber; } string& getBody() { return body; } const string& getBody() … | |
Re: [code=c++] inline unsigned getMin(uint32_t t) { return (t/60)%60; } inline unsigned getHour(uint32_t t) { return t%3600; } inline unsigned getSec(uint32_t t) { return t%60; } inline uint32_t makeTimeOfDay(unsigned h, unsigned m, unsigned s = 0) { return s + 60*m + 3600*h; } inline // returns interval abs value uint32_t … | |
Re: The last question: where is [b]Modular Programming[/b] in OP snippet? ;) | |
Re: [QUOTE=pranjalkumar;852299]I have an assignment in which I have to create a 16-byte float, allocating bits to mantissa, exponent, sign of mantissa and sign of exponent at my own discretion. I have planned it to be as follows - Bits Purpose 1 Sign of mantissa 2 – 32 Mantissa 33 Sign … | |
Re: It's so simple: you need the [b]third[/b] member function (may be protected or private): [b]search[/b]. It's exactly what you are trying to do in both functions inside so strange try block (no need in exceptions to control a simple found/not found condition). | |
Re: `static Singleton* obj = 0;` is a local static variable definition (declaration + initialization). An implementation is permitted to perform so called early initialization of the obj (before `Singleton::getInstance` call) or to perform it at the first entry to the getInstance. Avoid recursive initialization of local variables with static storage … | |
Re: Probably the simplest way to go: [code=c++] #include "../projectBfolder/B.h" [/code] or add the project B folder to include paths list of the project A. How to do it depends on your IDE, of course... | |
Re: 1. What's [i]the quality of a picture[/i]? Imagine 1-pixel picture... 2-pixels picture... and so on ;) 2. There are lots of C and C++ libraries (search Google). I think now most of graphics applications are written in C and C++. What's a picture? It's a file. What's a file? It's … | |
Re: A recursion does not bear a relation to your problems with cin. You never get a single keystroke from the cin stream until press Enter. The cin stream is not a keyboard (console) device. Moreover, after cin.get() the next waiting char '\n' (end of line) is still in the cin … | |
Re: [QUOTE=pranjalkumar;849969]I want to create a 16-bit float datatype, allocating memory to exponential and mantissa part at my own discretion. How can I do that?[/QUOTE] Do you want a portable solution? No: use short int (if it occupies exactly 16 bits on the target platform)... Yes: use [icode]class TinyFloat {... unsigned … | |
Re: >how to link the header files to c code????? I have a good news for you: no needs to [i]link[/i] header files to c codes! The #include directive is replaced by the content of included file - that's all. Yet another good news: no needs in full scale C compiler … | |
Re: What a strange code! All image elements points to the same memory (an array colour). Probably there are some other defects but it's a full stop. In actual fact you didn't get any useful data from the file. Your array image is an array of pointers, not an array of … | |
Re: Start from [url]http://en.wikipedia.org/wiki/B-tree[/url] | |
Re: 1. Don't worry: {} is not an operator. 2. An object has a state so you can incapsulate essential context info for future calls. 3, No such thing as a CPU serial number (CPU ID) in modern Intel processors. To get other CPU parameters: see Intel Architecture Software Developer's manual … |
The End.