1,296 Posted Topics

Member Avatar for abcd_nima

Alas, do not use all stilllearning's methods (sorry, stilllearning ;)). The safe method: [code=cplusplus] std::string foo(.......) { // not string& !!! char buf[...]; // form buf contents return buf; // don't worry: it returns string object } // or if you don't know max buf size std::string bar(.....) { std::string …

Member Avatar for ArkM
0
118
Member Avatar for monkey_king

To all appearances you are trying to reinvent std::valarray class ;). Look at <valarray> header of your C++ installation. For example, in MS VC++ 9 you can see: [code=cplusplus] template<class _Ty> class valarray { // store array with various indexing options ... valarray<_Ty> operator+() const { // return +valarray _VALOP(_Ty, …

Member Avatar for monkey_king
0
149
Member Avatar for ashkash

Hmm, hex manipulator on the C language forum... Be afraid of pure C fanatics ;)...

Member Avatar for ArkM
0
97
Member Avatar for JackDurden

Of course, the C++ compiler does not like overloaded shift operator with string left operand. You want [icode]insert >> word[/icode], right? A very unfortunate name for input stringstream: insert...

Member Avatar for Narue
0
121
Member Avatar for Mumo

What's a wonderful nightmare code! ;).. Log10 denotes decimal (base10) logarithm. Obviously, you want [code=c] log((double)INT_MAX)/log(2.0) + 1 [/code]

Member Avatar for ArkM
0
98
Member Avatar for kux

I think it's a very interesting question. From the C++ Standard (4.5, 1): [quote]An rvalue of type char, signed char, unsigned char, short int, or unsigned short int can be converted to an rvalue of type int if int can represent all the values of the source type; otherwise, the …

Member Avatar for kux
0
133
Member Avatar for Hinche4

Yet another wrong code fragment: [code=cplusplus] #define ROWS 2 #define COLUMNS 2 ... for (i=0; i<3; i++) { // *** < 2 or better < ROWS for(j=0; i<3; i++) // *** j++ !!!; // *** < 2 or better < COLUMNS cout << Screen_Array[i][j]; } [/code]

Member Avatar for ArkM
0
311
Member Avatar for shinta13

You try to get tax_rate with wrong format specifier (%d used only for int values but your tax_rate is float). Must be: [code=c] scanf("%f", &tax_rate); [/code] Better use double type for all your numbers. Don't forget that input format specifier for double is %lf, not %f.

Member Avatar for stilllearning
0
102
Member Avatar for plenitude

Sacramental phrase: Google is your friend... [url]http://support.microsoft.com/kb/828736[/url]

Member Avatar for ArkM
0
153
Member Avatar for daviddoria

Non-static member function always called for the object, not in itself. The glutMouseFunc does not know, which object used for member function call. So it's no sense to pass a member function pointer to glutMouseFunc: it can't use such a pointer. In other words, a pointer to a function is …

Member Avatar for kux
0
670
Member Avatar for AutoC

What is meant by pseudo-eof? If it's EOF macros from C stdio.h header then it's not a char value, it's int type value returned by stream input functions. So this EOF is not a char from the file (and no problems with 8-bit or 16-bit values at all). Take into …

Member Avatar for ArkM
0
135
Member Avatar for jhonnyboy

[quote]The txt file has numbers and the only way i can put them into an array is to put them into a char array.[/quote] Why?!.. Do you know that unsigned char range is 0..255 only? [quote]the numbers in the txt file are as long as 10,000 per line. The char …

Member Avatar for Sci@phy
0
141
Member Avatar for melissajohn718

Probably you forget to start your main function from its header int main(): [code=cplusplus] #include <iostream> using namespace std; int num; int main() // ????????????? { [/code] ;) Why int num declared on global level?..

Member Avatar for VernonDozier
0
196
Member Avatar for DevC++4.9.9.2

Sorry, but parameter [icode] string array[100][/icode] is equivalent of pointer to array of strings passing, so it's correct way to go...

Member Avatar for Salem
0
182
Member Avatar for sunveer

Yet another prompting: X(1) + X(2) + ... +X(n)+... X(1) = x X(n) = (+/-)x*x*...n times / (1*2*...*(n-1)*n) = (-x/n) * X(n-1) It's so simple ;)...

Member Avatar for stilllearning
0
88
Member Avatar for babiker

1. In C++ we must declare all names before using. From the C++ Standard: [quote]Declarations specify how names are to be interpreted.[/quote] Function prototype is the most common form of function name declaration. Function header + function body called function definition. A definition is a declaration too. So you must …

Member Avatar for ArkM
0
98
Member Avatar for eehyf

Well, and what's your problem? [code=cplusplus] Contact todo("Please","look@your.textbook","12345"); todo.print(); [/code] Is it a problem?

Member Avatar for eehyf
0
192
Member Avatar for wolih

Another way to correct situation: make help(), quit(), finished and action_index members static. In that case you can add pointers to help and quit functions to action_index map. Pointers to static member functions are the same as usual pointers.

Member Avatar for wolih
0
139
Member Avatar for cam875

Some remarks. String handling per se is a smallest part of a scanner - the simplest component of any compiler. No problems to implement effective scanners in C or C++. Syntax parsers and code generators (main parts of compilers) work with internal data structures and does not take trouble over …

Member Avatar for ArkM
0
141
Member Avatar for astropirit

If you have (void*) pointer p to byte-addressable memory then you can add byte offset A0 to it with a very simple expression: [code=c] p = (char*)p + 0xA0; [/code] Dirty job, eh?..

Member Avatar for ArkM
0
422
Member Avatar for eehyf

Let pnode is a pointer to a DLL_node. Now [code=cplusplus] pnode->contact->print(); [/code] prints this node. Can you write the code traversed linked lists from the head to the tail? Is it your "problem behind problem"?

Member Avatar for eehyf
0
126
Member Avatar for skatamatic

You are looking for a deep copy silver bullet but your compiler does not know the semantics of this operation for your classes. YOU know the semantics. That's why user-defined copy constructor and overloaded assignment operator were invented in C++. It's a matter of the right object model design. For …

Member Avatar for skatamatic
0
248
Member Avatar for kux

It's not an optimizing compiler, it's a linker does it! That's why static libs were invented many many years ago ;)...

Member Avatar for ArkM
0
108
Member Avatar for stormtr00per

It's absolutely senseless statement in C++: [code=cplusplus] char message[] = the_date[12]; [/code] You try to declare an array of unknown size, so you must provide brace-enclosed initializer-list with constant initializers or string literal (see declaration of oldname), but the_date[12] in this context denotes non-existing 13-th element of the_date array (it's …

Member Avatar for Ancient Dragon
0
121
Member Avatar for shamila08

It seems this function had its Fortran prototype, so indicies started from 1 to N (and right corrected dimension bound N+1): typical ad hoc porting solution. Better give us a reference to this alg method and source (present data file contents too). I have some doubts about the algorithm. It …

Member Avatar for shamila08
0
121
Member Avatar for balakrishnan.kb

See, for example: [url]http://en.wikipedia.org/wiki/Virtual_function[/url] [url]http://www.codersource.net/cpp_virtual_functions.html[/url]

Member Avatar for Narue
0
109
Member Avatar for Hannahlv

Let one (anyone) client is appointed "p2p server" and another client is appointed "p2p client" by the server. [quote]I can write the program that let server and client connect[/quote] That's all - you know the right solution. After p2p connection establishing they will have only p2p protocol troubles as was …

Member Avatar for Hannahlv
0
447
Member Avatar for shamila08

Never use a very expensive pow() function in this context. You want to change subexpression sign for odd p only. Make it explicitly, it's much more faster code: [code=cplusplus] temp = b[0][p]*determinant(c,m-1); if ((p&1) != 0) sum -= temp; else sum += temp; return sum; [/code] or, may be [code=cplusplus] …

Member Avatar for Nick Evan
0
117
Member Avatar for meabed

Yes, it's the simple truth but not the complete truth, see also [url]http://www.codeproject.com/KB/cpp/howto_export_cpp_classes.aspx[/url] ;)

Member Avatar for ArkM
0
850
Member Avatar for Clockowl

All C compilers create all arrays as 1D arrays: the C language defines a strict mapping of multi-dimentional array to contiguous 1D array...

Member Avatar for grumpier
0
90
Member Avatar for brent.lozano001

1. Regrettably, for negative numbers williamhemsworth's solution does not work (moreover, gives wrong result - for example, it yields 0 for -0.9 but nearest integer value for -0.9 is -1). Right solution: [code=cplusplus] #include <cmath> ... double round(double x) { bool negative = false; if (x < 0.0) { x …

Member Avatar for ArkM
0
248
Member Avatar for coveredinflies

In addition, operator= sceleton should be: [code=cplusplus] ThreeD& operator=(const ThreeD& op2) { if (this != &op2) { .... } return *this; } [/code]

Member Avatar for vijayan121
0
191
Member Avatar for GamesSmash

May be better ask on 7-Zip forum? [url]http://sourceforge.net/forum/forum.php?forum_id=45797[/url]

Member Avatar for GamesSmash
0
173
Member Avatar for xr0krx

Generally speaking getch() is not "Borland specific". It's a function declared in <conio.h> - commonly used and partially supported but not standardized console input/output header. Sometimes its name is _getch() but as usually in that case conio.h includes macros for "deprecated" getch. It's impossible to inplement full getch() functionality with …

Member Avatar for Narue
0
119
Member Avatar for policeachan

Regrettably, I do not know who was the 1st author of the printf source. There are many implementations of printf. Google search for "printf source code" returns lots of links, for example: [url]http://www.menie.org/georges/embedded/index.html#printf[/url] [url]http://www.sparetimelabs.com/tinyprintf/index.html[/url] etc... You may download GNU clib sources or buy Visual Studio with RTL sources. Write your …

Member Avatar for Narue
0
170
Member Avatar for cy163

On the codeguru forum author of SynchronizedQueue wrote to his correspondent: [quote]Do you have any experience in c++ programming? the reason I'm asking is because it's crucial to applying the scheme I've supplied before.[/quote] The same question to you?..

Member Avatar for cy163
0
144
Member Avatar for Helgso

1. Add #include <string> 2. Add [code=cplusplus] string path; ...// get dir name into buf then path = buf; path += "System\\Unreal.exe"; // Now you have string path with // "F:\Tolvuleikir\Full\FPS\Unreal Anthology\UnrealGold\System\Unreal.exe" system(path.c_str()); // Start the application [/code] 3. Don't muddle double backslashes in source text literals with "friendly executable …

Member Avatar for Helgso
0
333
Member Avatar for want_somehelp

1. You forget semicolon after if statement: [code=cplusplus] if (*p) p++; // *** *q = '\0'; [/code] 2. Use code tag for your snippets on this forum: [noparse][code=cplusplus] your code [/code][/noparse] 3. Make a proper source code indentation. You write C++ programs, not adult's graffiti...

Member Avatar for ArkM
0
144
Member Avatar for john88

I think the right solution is std::map<std::string,int> (another name of map is dictionary). Fast search, automatic sorting + Ancient Dragon's counter - three in one solution.

Member Avatar for john88
0
94
Member Avatar for bhoot_jb

No compiler error when you compile THIS code with Object and Pont declarations only. Of course, you can't create this class Point object because of it does not implement all Object interaface and therefore it is an abstract class too. Let's start from the class Object redesign: 1. The setCoords() …

Member Avatar for bhoot_jb
0
116
Member Avatar for phillipeharris

I don't know why but merge_sort function in attached file is a senseless text in unknown language (it's not C and C++). Look at the correct merge sort implementation in C++: [url]http://www.algorithmist.com/index.php/Merge_sort[/url] [url]http://www.algorithmist.com/index.php/Merge_sort.cpp[/url] May be it helps...

Member Avatar for ArkM
0
190
Member Avatar for Sci@phy

As far as I know flag/lock file method works on all platforms. See discussion on this topic: [url]http://www.velocityreviews.com/forums/t137115-preventing-multiple-instance-standalone-desktop-gui-applications.html[/url]

Member Avatar for Duoas
0
409
Member Avatar for Congartis

Bresenhamn's optimized algorithm initializes deltax, deltay and error AFTER swappings. Your program initializes them BEFORE swappings. Why?..

Member Avatar for Congartis
0
651
Member Avatar for TooMpa

It seems you don't understand basics of dynamic memory allocation: 1. struct node has char*name member (pointer to char) but you don't allocate memory for name object. So you have garbage pointer values in uninitialized structures. Use malloc to allocate memory and save pointers to these structure members for all …

Member Avatar for ArkM
0
204
Member Avatar for man4ish

1. Use code tag to present your snippets: [noparse][code=cplusplus] your code [/code][/noparse] 2. Stop this terrible source alignment! Use indentation. 3. You declare uninitialized pointer to substr class object (s). But where is the object? 4. Your substr class contains the only (and very dangerous) member function. It's a very …

Member Avatar for iamthwee
0
82
Member Avatar for devnar

Stricktly speaking it's possible and valid behaviour of floating-point calculations. Floating point types are not mathematical real numbers. The last ones have "infinit" precision but doubles and floats are approximations of real numbers. So C language literal 0.7 is an approximation (of double type by definition) of the real number …

Member Avatar for smart_pc
0
586
Member Avatar for defychaos

There are lots of undeclared identifiers in your snippet. May be better post the source after you (and me) can compile it w/o errors?

Member Avatar for defychaos
0
213
Member Avatar for rkumaram

It seems you have much more problems, for example: [code=cplusplus] base crash(0); // why not? [/code] How about strlen(0) in your constructor? Yet another example: [code=cplusplus] { base bomb; // Default constructor do not initialize name member! ... } // Bang! Dectructor delete something via non-initialized pointer... [/code] How to …

Member Avatar for rkumaram
0
113
Member Avatar for reshma.mane

What data structures you consider Advanced? Try to implement a very fast (and huge) priority queue with erase by key operation...

Member Avatar for Alex Edwards
0
101
Member Avatar for BeyondTheEye

Compile your project in VC++ 2008 as a console (not Forms) application and you will get the same result as in Code::Blocks (probably, your Code::Blocks IDE used VC++ to make console application)...

Member Avatar for Narue
0
267

The End.