1,296 Posted Topics

Member Avatar for oling

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 …

Member Avatar for ArkM
0
185
Member Avatar for manish_fra

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.

Member Avatar for ArkM
0
67
Member Avatar for spanigrahi_situ
Member Avatar for Salem
0
2K
Member Avatar for mrnutty

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? ;)

Member Avatar for dmanw100
0
136
Member Avatar for matt_570

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: …

Member Avatar for matt_570
0
4K
Member Avatar for JD2000

[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 ;)

Member Avatar for JD2000
0
135
Member Avatar for johnalexandersr

Are you sure that Daniweb is better than Goodge to search in INET? [url]http://www.algorithmist.com/index.php/Merge_sort.c[/url]

Member Avatar for Freaky_Chris
0
168
Member Avatar for rpg245

~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 ;)

Member Avatar for Salem
0
110
Member Avatar for nedsnurb

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]

Member Avatar for ArkM
0
96
Member Avatar for atman

[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 …

Member Avatar for WaltP
0
153
Member Avatar for inktri

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.

Member Avatar for kux
0
445
Member Avatar for wizzsm

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 …

Member Avatar for wizzsm
0
697
Member Avatar for axelgeorge

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]

Member Avatar for Freaky_Chris
0
103
Member Avatar for CE Student

[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 …

Member Avatar for Lerner
0
1K
Member Avatar for aamresh1

[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 …

Member Avatar for ArkM
0
89
Member Avatar for himanjim

[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;)

Member Avatar for Freaky_Chris
0
153
Member Avatar for ItecKid

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 …

Member Avatar for ArkM
0
642
Member Avatar for kodak

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.

Member Avatar for kodak
0
122
Member Avatar for bradbobak
Member Avatar for bradbobak
0
303
Member Avatar for 666kennedy

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?

Member Avatar for ArkM
0
155
Member Avatar for gm999

[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 …

Member Avatar for gm999
0
88
Member Avatar for lehe

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 …

Member Avatar for ArkM
0
90
Member Avatar for samishunk

Are you sure that daniweb is the best place for lazy pupils? Read this: [url]http://www.daniweb.com/forums/announcement8-2.html[/url]

Member Avatar for samishunk
0
188
Member Avatar for Dewey1040

Through overboard your snippet. [code=c] int n; /* elements counter */ ... for (n = 0; fscanf(fin,"%d",&A[n])==1; ++n) ; [/code] ;)

Member Avatar for ArkM
0
96
Member Avatar for jbody

[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 …

Member Avatar for ArkM
0
119
Member Avatar for Freaky_Chris

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 …

Member Avatar for StuXYZ
0
263
Member Avatar for blazen

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 …

Member Avatar for ArkM
0
138
Member Avatar for AdRock

[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] …

Member Avatar for ArkM
0
3K
Member Avatar for sid78669

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 …

Member Avatar for sid78669
0
213
Member Avatar for MattEvans

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& …

Member Avatar for MattEvans
0
222
Member Avatar for christiangirl

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++] …

Member Avatar for christiangirl
0
155
Member Avatar for Headerandy

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 …

Member Avatar for Headerandy
0
116
Member Avatar for namehere05

Remember the K&R masterpiece: [code=c] while (*dest++ = *src++); [/code] Unforgettable Algol 68's genes are still alive in C and C++ ;)...

Member Avatar for namehere05
0
614
Member Avatar for java_girl

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 …

Member Avatar for devnar
0
11K
Member Avatar for Prashant45

Write [b]initgraph[/b], not intigraph ;) Don't waste a time and traffic on this funny "problems"...

Member Avatar for ArkM
0
2K
Member Avatar for karang

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; }; …

Member Avatar for ArkM
0
191
Member Avatar for Proseidon

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 …

Member Avatar for ArkM
0
156
Member Avatar for Foe89

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] …

Member Avatar for Foe89
0
284
Member Avatar for mbayabo

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 …

Member Avatar for grumpier
0
118
Member Avatar for quocnam00

It's so simple: exactly [icode]sizeof(void*)[/icode]. Let the interviewer counts ;)

Member Avatar for Narue
0
179
Member Avatar for java_girl

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 …

Member Avatar for Luckychap
0
233
Member Avatar for karang

[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?

Member Avatar for cikara21
0
163
Member Avatar for MMac1218

Look at your colleague's meteorological suffering: [url]http://www.daniweb.com/forums/thread160190.html[/url]

Member Avatar for nmaillet
0
107
Member Avatar for ahspats

[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]

Member Avatar for ahspats
0
125
Member Avatar for Dontais

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 …

Member Avatar for Dontais
0
107
Member Avatar for cubathy

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]

Member Avatar for cubathy
0
110
Member Avatar for f.ben.isaac

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 …

Member Avatar for f.ben.isaac
0
244
Member Avatar for sid78669

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 …

Member Avatar for ArkM
0
143
Member Avatar for drjay1627

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 …

Member Avatar for ArkM
0
128
Member Avatar for AutoC
Member Avatar for ArkM
0
228

The End.