1,296 Posted Topics
Re: An IDE (Integrated Development Environment ~= text editor+compiler+code browser+linker+debugger etc bears no relation to the desired functionality. There are lots of methods to do that (besides OS-specific connections of program console i/o to the remote terminal client). For example, you may write your program as CGI (or better FastCGI) requests … | |
Re: Read the package docs before use it. [url]http://www.shoup.net/ntl/doc/tour-win.html[/url] Evidently you did not create NTL modules static library and/or did not include package sources in your project. | |
Re: Can you explain what is meant by "unix timestamp" and (mainly) "system timestamp"? | |
Re: Hehe, don't force an open door: [code=c++] "AQKJ"[rand()%4] [/code] About [icode]{1,...,10,A,Q,K,J}[/icode] question: are you sure that "10" is a character? Or TWO characters? ;) | |
Re: You have two different problems: 1. Tokenize the input stream (extract words from the stream). 2. Build word dictionary. The second one has a very simple solution: use std::<map> data structure as Laiq Ahmed mentioned above. However you need another code to process every word with the map-based word dictionary: … | |
Re: [QUOTE=JD2000;750490]So I think I now have Ship*&, which should actually be Ship&. Is there any way to convert Ship*& to Ship&? [/QUOTE] Yes, of course: use unary operator *(). But I'm not sure that it helps ;) | |
Re: Are you sure that Daniweb is better than Goodge to search in INET? [url]http://www.algorithmist.com/index.php/Merge_sort.c[/url] | |
Re: ~35 millions pseudo-random numbers per second with VC++ 2008 compiler - are you sure that it's too slow for your application? Well, look at [url]http://www.firstpr.com.au/dsp/rand31/[/url] or simply try Google "fast pseudorandom generator" - tons of links ;) | |
Re: Keep it simpler ;) [code=c++] void OrderedList::insert(int val) { ListItem* prev = 0; ListItem* curr = head; while (curr && curr->getValue() < val) { prev = curr; curr = curr->getNext(); } ListItem* pnew = new ListItem(val,curr); if (prev == 0) head = pnew; else prev->setNext(pnew); } [/code] | |
Re: [QUOTE=atman;751389]could anybody please help imbeding fgets() to read 1 letter from stdin? do i have to create array for this? do i have to include a pointer to char in fgets() argument? once its read i have to extract the value from the buffer to memory? could anyone please help … | |
Re: Obviously the possible solution depends on the general architecture of your application (and run-time environment). In standard C++ an object life time defined with regard to the only execution thread and it's not a real time. | |
Re: 1. You got UNICODE string so convert it in (almost) ordinar C-string before pass it to std::string constructor. [code=c++] char cstrValue[1024]; ... if (WideCharToMultiByte( CP_ACP, 0, rgValue,-1,cstrValue,sizeof cstrValue, 0,0)) { // you got it! You may printf cstrValue } [/code] 2. Don't pass std::string in printf directly, std::string object is … | |
Re: The [icode]std::vector::at[/icode] member function is not identical to [icode]std::vector::operator[][/icode], use [icode](*PtrMyVector)[i][/icode]. In actual fact better pass vector by reference: [code=c++] void ReadMyVector(vector <int>& PtrMyVector); [/code] | |
Re: [QUOTE=CE Student;751460][COLOR="Red"]int maxSize=14; int inputArray[maxSize]=(60,50,70,30,53,80,35,57,75,32,40,77,48,45);[/COLOR] Another thing i do not konw how to initilize this array[/QUOTE] 1. Use braces [icode]{...}[/icode] instead of parentheses for initializator-list. 2. Avoid using red color (and other rainbow) effects. For example I (and may others) hate long red lines ;) 3. Use code tags for … | |
Re: [QUOTE=aamresh1;751596]What sort of number does gmp.h generate - Binary or Decimal? Please need the answer a bit quickly. Amresh.[/QUOTE] Probably an unknown gmp.h is a header file. If so it can't "generate" any "numbers". If you ask about well-known GMP library then what kind of numbers did you mean? If … | |
Re: [QUOTE=himanjim;392706]For e.g the complexity of bubble sort is Average Case=>O(n*n) Worst Case=>O(n*n) Best Case=>O(n*n)[/QUOTE] Apropos, the best case compexity of bubble sort with swapped flag improvement is O(n) - it stops after the 1st pass;) | |
Re: Irrespective of hidden errors in your code (I'll see them later) some remarks: 1. An std::vector object data area IS an array. An address of the 1st vector element points to the start of the vector data array. So your comparative studies are aimless ones: you may sort a vector … | |
Re: If you define relative file name (not full path - for example, "name.txt" only) then it's not a Vista problem. At run-time the current directory is not the same as exe module directory so the program can't access external files via relative file names. | |
Re: Why not? It's the address of the same object called inst. | |
Re: Yes, the C library function rand() has no arguments at all. Why [icode]rand(CHR/2)[/icode] and [icode]rand(GENE)[/icode]? What's that special rand with argument? What's your problem with this obvious compiler message? | |
Re: [icode]int* a[/icode] parameter treated as a local variable in the function body. See what happens when you call the function: [code=c++] size_t n = 2008; int* parr = new int[n]; // parr points to a new memory chunck of 2008 integers. ... newInt(2008,parr,n); // pointer parr value initializes local a … | |
Re: Of course, it's incorrect result because your compar is wrong. Read qsort specification carefully. That's a quote from the C language standard: [quote]The contents of the array are sorted into ascending order according to a comparison function pointed to by compar, which is called with two arguments that point to … | |
Re: Are you sure that daniweb is the best place for lazy pupils? Read this: [url]http://www.daniweb.com/forums/announcement8-2.html[/url] | |
Re: Through overboard your snippet. [code=c] int n; /* elements counter */ ... for (n = 0; fscanf(fin,"%d",&A[n])==1; ++n) ; [/code] ;) | |
Re: [QUOTE=jbody;750440]There is something that I saw and wanted to check if it is really wrong, as I thought. In the second edition of The C Programming Language 2nd ED by Brian Kernighan and Denis Ritchie, in the section of 5.2 Complicated Declarations, in page 109, it is written so, isn't … | |
Re: It's not an "old compiler" issue, it's normal behaviour for floating point data calculations. You have not the right to an "exact" result for these calculations. Only integral numerical types get "exact' results. The "obscure" value -5.77338e-017 is a good approximation for least valued bits of double type mantissa. Now … | |
Re: Your substr function returns a pointer to its local variable str. This automatic storage variable are discarded immediatly after return, so this pointer value is senseless one. The classical novice's error ;) The second defect: you forgot to append terminated null byte at the end of the formed substring. The … | |
Re: [quote]I got this code from a C++ book...[/quote] I think no books with such absurd codes ;) For example: [code=c++] char FileName[20]; ... ifstream myfile(FileName); ... // Is eof() a member of CHAR ARRAY FileName??? while (! FileName.eof()) //Loop through lines [/code] Never, ever scan files with [icode]while (! file.eof())[/icode] … | |
Re: Alas, your attempts to get direct access to the class Account private members display only your C++ and OOP knowledge (and programming skill level ;) ). The Account class designer declared public interface to ordinar class clients. Nobody should try to get more: that's class designer decision. Do you want … | |
Re: The C++ Standard: [quote]A non-template constructor for class X is a copy constructor if its first parameter is of type X&, const X&, volatile X& or const volatile X&, and either there are no other parameters or else all other parameters have default arguments (8.3.6 ). Example: X:: X(const X& … | |
Re: You have invented a rather strange one-time list where new members are inserted in the head and the first traversal is at the same time the last possible one. After the 1st call of (incorrect) printarea the list becomes unusable. It losts all elements. Well, non-destructive Dynamic::printarea looks like [code=c++] … | |
Re: 1. Next time use code tag with the language specifier for code snippets: [noparse][code=cplusplus] your code [/code][/noparse] 2. You accumulate all input file contents line by line in the stringstream sstr variable. Insert [icode]cout << sstr.str() << endl;[/icode] statement after [icode]sstr << x;[/icode] and try this on a small input … | |
Re: Remember the K&R masterpiece: [code=c] while (*dest++ = *src++); [/code] Unforgettable Algol 68's genes are still alive in C and C++ ;)... | |
Re: Wrong using of a POINTER constant defined as NULL macros in C: [code=c] while( str1[i] != NULL) /* wrong */ /* Right code: */ while (str1[i]) /* (I prefer this form); or */ while (str[i] != '\0') /* or */ while (str[i] != 0) [/code] The C compiler can define … | |
Re: Write [b]initgraph[/b], not intigraph ;) Don't waste a time and traffic on this funny "problems"... | |
Re: 1. Use code tags: [noparse][code=c++] ... sources .. [/code][/noparse] 2. If class IClassFact is not defined in the incude point, use incomplete type declaration just before class Test definition: [code=c++] class IClassFact; // this is a class name, I'll define it later class Test { ... ... IClassFact* m_pClassFact; }; … | |
Re: Start from the beginning: [code=c++] List_3358<int> *newList=new List_3358<int>[33971]; [/code] A magic number (explicit int constant > 2 - bad style). Possible solution: [code=c++] const size_t TABLESIZE = 33971; // what is it and why... typedef list<int> VChain; ... VChain* pHash = new VChain[TABLESIZE]; [/code] An example of a wrong code … | |
Re: Only getTotal code is correct. All three other fuctions are wrong. 1. getAverage: use getTotal to obtain a sum of all elements then divide sum by the number of elements! 2. getLargest and getSmallest: why [icode]double largest = array[100];[/icode]?! No such element in the array at all. Start from [icode]array[0][/icode] … | |
Re: What's a problem? [code=c++] class A { public: A() {} explicit A(const std::string& n):name(n) {} const std::string& getName() const { return name; } protected: std::string name; }; inline std::ostream& operator<<(std::ostream& os,const A& a) { os << a.getName(); return os; } class B: public A { public: B():A() {} explicit B(const … | |
Re: It's so simple: exactly [icode]sizeof(void*)[/icode]. Let the interviewer counts ;) | |
Re: Some additions: 1. To print pointer value use %p (not %d) format specifier. As usually, it's a senseless operation ;). 2. True type of a string literal is [icode]const char*[/icode] - a constant pointer to the 1st element of a char array contained a string with terminated null character. You … | |
Re: [QUOTE=karang;747992]Hi I have include a header file in my main file. That header file contains the function getPath But still I am getting this error error C3861: 'getPath': identifier not found Even I have written the prototype of the function. Regards Karan[/QUOTE] Hi. Accept my condolences. And what's your question? | |
Re: Look at your colleague's meteorological suffering: [url]http://www.daniweb.com/forums/thread160190.html[/url] | |
Re: [code=c++] n = strlen(nummer); for (int i = 0; i < n; i++) { if (nummer[i] <= '0' || nummer[i] >= '9') { for(int j = i; j < n; j++){ nummer[j] = nummer[j + 1]; ... [/code] | |
Re: A function can't "call a variable". It may be called (from another functions) and may call another functions. The parameter name "answer" in cosx header does not bear a relation to a word "answer" in the main function body. You must declare int variable (called answer or what else) in … | |
Re: Read the compiler message: [icode]operator [][/icode] MUST be non-static member of a class. No [icode]operator[][/icode] in X class definition. Three operators must be non-static members in C++: [code=c++] operator= operator[] operator-> [/code] | |
Re: 1. Obviously, you are wrong. The CSocket object IS NOT equivalent of socket() function call or a "slow variant of a socket handler". Look at the CSocket class description: [url]http://msdn.microsoft.com/en-us/library/wxzt95kb(VS.80).aspx[/url] The class CSocket presents ready-to-use high level abstraction of a socket with a set of common and useful operations with … | |
Re: In modern C++ the global default operator new never returns 0. If it's impossible to obtain sufficient storage then std::bad_alloc exception raised. Of course you can catch this exception but as usually the best choice is to abort the program. If you want to get 0 in that case use … | |
Re: Regrettably both code snippets are absolutely senseless. May be better post us your map building code? Is its quality the same? You need to iterate a source string word by word, not a map. You must get WORDS from the source string, not chars. Use istringstream to extract words from … | |
Re: See also [url]http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html[/url] |
The End.