1,296 Posted Topics

Member Avatar for Prm753

The last char in the registryHive buffer after fgets() call is '\n' if it was a well-formed text file. Of course, it's not a part of registry key...

Member Avatar for ArkM
0
150
Member Avatar for mancode1007

Alas, the %s format specificator reads only one word from the stream (for example, it reads from the 1st record Smith only but not Smith Allison. After that your fscanf wants to read integer but gets Allison and returns. The next fscanf starts from the current file position (on Allison …

Member Avatar for jephthah
0
2K
Member Avatar for kinger29

Never define global variables in .h files! You can declare these variables, of course - simply use extern keyword before its type, but define such variables in one and only only cpp file. As usually, there are better solutions than global variables using, but it's the other story. The key …

Member Avatar for ArkM
0
135
Member Avatar for gregorynoob

It's a slow O(n*n*n) with not optimal implementation solution. It works (I have a proof of the algorithm correctness): [code=cplusplus] int setRank(const int* a, int n, int* b) { int tot = 0; for (int v, s, k = 0; k < n; ++k) { if (b[k] >= 0) { …

Member Avatar for ArkM
0
103
Member Avatar for Opsive

See also [url]https://www.securecoding.cert.org/confluence/display/seccode/MSC05-C.+Do+not+manipulate+time_t+typed+values+directly[/url] and [url]http://en.wikipedia.org/wiki/Time_t[/url]

Member Avatar for Radical Edward
0
2K
Member Avatar for symas

No any member (variables, functionc etc) names at run time. Your running (compiled, linked and loaded) program is a block of machine commands and constants - an easy and healthy food for processor(s)...

Member Avatar for Radical Edward
0
299
Member Avatar for yazooney

Do you want to know: 1. ...where to buy VC++ Pro or 2. ...how to commit a crime ?

Member Avatar for ArkM
0
137
Member Avatar for bomtk

1. Use CODE tags for your code snippet: [noparse] [code=cplusplus] your code here [/code] [/noparse] 2. Try to correct absolutely barbaric text indentation. 3. Invalid file opened check in the loop, must be: [code=cplusplus] if (!fin /*!file_name*/ ) { cerr << "Error: file #" << m << " could not …

Member Avatar for bomtk
0
133
Member Avatar for sreesai

Must be [icode]char* foo ( const char *msg ) {[/icode], of course ;)...

Member Avatar for dwks
0
129
Member Avatar for Clockowl

Moreover, never use std::vector instead of plain arrays in time-bounded sections of your codes. For example, see vector/array timing in the bottom of my snippet source: [url]http://www.daniweb.com/code/snippet916.html[/url]

Member Avatar for Clockowl
0
210
Member Avatar for thatoneguyx

As is well known Bloodshed Dev-C++ and Code::Blocks are IDE, not compilers. Dev-C++ is a dead project, so better download and install a very good Code::Blocks IDE with MinGW C++ compiler bundled: [url]http://www.codeblocks.org/[/url] It seems Visual Studio 2008 Express is OK but the author can't select right project parameters (it's …

Member Avatar for ArkM
0
122
Member Avatar for aalhamad

I don't understand: 1. ... your sorting criteria. Values in (columns?) #1, #2, #4 are in increasing order but in #3 in decreasing. Why? 2. You have used a map. What for?

Member Avatar for ArkM
0
91
Member Avatar for nimloman

Never forget to test end of stream condition (avoid loop forever): [code=cplusplus] const int eof = char_traits<int>::eof(); int ch, n; for (;;) { cout << ">"; cout.flush(); for (n = 0; (ch=cin.get()) != eof && ch != '\n'; ++n) { // process ch as you wish } if (!cin) break; …

Member Avatar for ArkM
0
113
Member Avatar for me_roy

Incorrect mx/mn assignment logic (think about why). Right solution: [code=c] // don't use float type, use double. double m[3][3] = // dont't use capital letters as var names ...; // it's not a good style double minval, maxval; for (int i = 0; i < 3; ++i) { minval = …

Member Avatar for WaltP
0
435
Member Avatar for loimarie

Hi the Grand Matematical Conclave... 2x^3 + x^2 is not a part of a LINEAR equation! That's a linear equation: A*x + B = 0 So ask a user to type A then B - that's all, your program is capable to print this equation solution now...

Member Avatar for jephthah
0
525
Member Avatar for techie2008

Well, let's remember C language (it's almost so called expression language) lexical grammar... Here it is expression part: [quote] C language expression tokens:: Identifiers:: all but sizeof <letter|_>[<letter>|_|<digit>]... ---------------------------------- Operators and punctuators:: one of [ ] ( ) : ? . + - * / % ^ & | ~ …

Member Avatar for techie2008
0
247
Member Avatar for ederX
Member Avatar for scjohnny

Well, let's start from this forum Announcement: [url]http://www.daniweb.com/forums/announcement8-2.html[/url]

Member Avatar for ArkM
0
77
Member Avatar for Clockowl

Use resize(n), not reserve(n) vector member function. The last one does not initialize vector elements, it only reserved memory for future vector grows.

Member Avatar for Clockowl
0
119
Member Avatar for glecymay

Sorry, I can't understand your question. Binary value... of what? The same counter-question about "to decimal value"...

Member Avatar for glecymay
0
195
Member Avatar for coveredinflies

Sorry, but [icode]char* ay[][255][/icode] declares 2D array of pointers to char. Probably, coveredinflies wants to pass an array as a function argument so right example is most likely [code=cplusplus] void foo(char ay[][255] ); [/code] But it's not the same as [code=cplusplus] void foo(char **ay); [/code] A pointer to an array …

Member Avatar for ArkM
0
455
Member Avatar for CoolGamer48

It's a common practice in C++ to implement Object-C @import semantics via sacramental [code=cplusplus] // Header file started... #ifndef HEADER_NAME_DERIVATIVE_ID #define HEADER_NAME_DERIVATIVE_ID // header contents here... #endif [/code] No special standard features in C++ and C preprocessors to do it. The #import preprocessor directive in MS Visual C++ has totally …

Member Avatar for Radical Edward
0
148
Member Avatar for robertmacedonia

It's not only a matter of personal preferences. I have seen codes where [icode]using namespaces std[/icode] provokes names conflict errors storm. Have you noticed that a code with explicit namespace prefixes is not depended of that "personal preferences" of its (future, unknown) users? It's especially concern of this (and similar) …

Member Avatar for William Hemsworth
0
256
Member Avatar for NekoGráfico

This code is an example of a fantastical C and C++ himera. If it's C, why constructors? If it's C++, why typedefs? Some notes. Let's start from trifles. 1. Try to follow common conventions. You are free in names choice (all but keywords) but as usually all-capitals are reserved for …

Member Avatar for NekoGráfico
0
106
Member Avatar for nadiasheikh

Better see: [url]http://www.partow.net/programming/hashfunctions/[/url] Download freeware C++ hash functions source codes (for std::string) from this site (~3Kb zip): [url]http://www.partow.net/downloads/GeneralHashFunctions_-_CPP.zip[/url] Download PDF chapter 18 (see 18.2, hash function for char arrays) - ~73 Kb: [url]http://www.uow.edu.au/~nabg/ABC/C18.pdf[/url] See also this textbook on C++ programming: [url]http://www.uow.edu.au/~nabg/ABC/ABC.html[/url] Look at hash functions written by professionals...

Member Avatar for CrazyDieter
0
105
Member Avatar for Manutebecker

Right now see your problem solution in the neighbours' thread: [url]http://www.daniweb.com/forums/thread139392.html[/url] (especially Salem's advice: random shuffling).

Member Avatar for JaR
0
116
Member Avatar for olagh

Of course, bigInt constructors must be public. But true reason of your troubles is incorrect RSA constructor. That's a right form: [code=cplusplus] RSA::RSA(unsigned m):n(m) {}; [/code] And no need in default constructor... More serious remark: presented RSA constructor does not initialize its bigInt member at all! See what happens: [code=cplusplus] …

Member Avatar for olagh
0
154
Member Avatar for JackDurden

It seems you try to catch a flea on the dead dog. Better leave in peace this ill-fated sorting. This program can't input data file! Start from the line 36 and totally revise literally every input statement...

Member Avatar for ArkM
0
158
Member Avatar for Psykocyber

As usually, a proper typedef helps to clear codes: [code=cplusplus] class Movie { typedef void (Movie::*MovieFunc)(); public: Movie() { f.push_back(&Movie::heHe); f.push_back(&Movie::haHa); } void show(int part) { (this->*f[part])(); } private: void heHe() { cout << "He he" << endl; } void haHa() { cout << "Ha ha" << endl; } vector<MovieFunc> …

Member Avatar for Psykocyber
0
5K
Member Avatar for denbecker

As far as I know, the only debug assertion in common STL stack container implementations rises when you try to pop an empty stack (Expression: deque empty before pop in Plauger's STL impl.). So revise your algorithm, trace test run step by step with debugger. I think, it's not so …

Member Avatar for Salem
0
118
Member Avatar for Black Magic

C or C++ program without functions is a nonsense. The 1st step on the right way: try to select code fragments to define usefull functions, for example: [code=cplusplus] int isHere(const int array[], int nelem, int number) { for (int i = 0; i < nelem; ++i) if (array[i] == number) …

Member Avatar for ArkM
0
385
Member Avatar for Agni

Try to compress: [code=cplusplus] bool Reverser(std::istream& sentence = std::cin, bool im1st = true) { std::string word; if (sentence >> word) { if (Reverser(sentence,false)) std::cout << " "; std::cout << word; if (im1st) std::cout << std::endl; return true; } return false; } [/code]

Member Avatar for Agni
0
348
Member Avatar for ++C LOVER

I have posted the answer yesterday but DaniWeb site discard it (why?). You can't redefine >> operator for bit fields because of no such animal as a reference to bit field in C++ language. Use intermediate int variable then assign it to the bit field - but it's not >> …

Member Avatar for Alex Edwards
0
579
Member Avatar for anshulagarwal

If you have old Borland's 16-bit compiler, I'm not sure that you can solve your problem with array size constraints. May be try: 1. Select huge memory model. 2. Declare global double* pointers d, d2, d3, d3 and allocate arrays dynamically [code] d = new double[5000]; ... and so on …

Member Avatar for jesseb07
0
147
Member Avatar for 2fac323

Better try these functions (don't cram a main story with <<...>> detail): [code=cplusplus] // Homework assignment: add comments... bool ack(const char* prompt = 0); inline bool ack(const std::string& prompt) { return ack(prompt.c_str()); } inline bool nak(const char* prompt = 0) { return !ack(prompt); } inline bool nak(const std::string& prompt) { …

Member Avatar for VernonDozier
0
203
Member Avatar for gregorynoob
Member Avatar for flipjoebanana

Alas, no any memory blocks in your snippet. You have two uninitialized pointers (both point to nowhere) - memory_block and array_of_floats. So you copy from nowhence to nowhere (with possible access violation, segment faults and other charms). Possible (but, strictly speaking, not conforming to the language standard) solution: [code=c] char …

Member Avatar for Ancient Dragon
0
99
Member Avatar for anshulagarwal

To compile your program w/o errors make some transformations: 1. Replace all float to double (use IDE Replace cmd). Never use float type in scientific/engineering calculations - use only double. 2. Correct two for loop headers [code=cplusplus] for(int s=0;s<g;s++) // add int s declaration [/code] 3. Move standard library includes …

Member Avatar for ArkM
0
427
Member Avatar for krebstar

[code=c] #include <ctype.h> // or #include <cctype> in C++ if (isascii(c)) {... [/code] It's the same as (c&~0x7F)==0...

Member Avatar for krebstar
0
6K
Member Avatar for davidleeis14

The last problem: Don't use [icode]ios::app|ios::ate[/icode] flags together: ios::ate suppresses ios::app and truncate the file (don't ask me why now;)). If you want to append new records use ios::app only. If you want to append a record then seek and write at any other place (it's not your case with …

Member Avatar for Agni
0
4K
Member Avatar for gispe

1. Where is a code snippet with this diagnostic message? 2. Presented source is obviously incorrect but it can't print a number. Why strcat? You print name and last_name but one line before strcat appends last_name to name... Never use [icode]cin >> char_array[/icode]! Type a long (>19 chars) name and …

Member Avatar for CoolGamer48
0
335
Member Avatar for krebstar

Where is it var declaration and initialization code? This pointer variable must refer to FILENAME object. Obviously, it points to nowhere...

Member Avatar for krebstar
0
192
Member Avatar for chanda gul

I don't know (have no needs) how to access floppies on physical level, but: 1. Use [noparse][code]...[/code][/noparse] tags to present your snippets. 2. Use [code=c] if (hFloppy != INVALID_HANDLE_VALUE) /* not if (hFloppy != NULL) - HANDLE is not a pointer! [/code] 3. A very strange, absolutely sensless code: [code=c] …

Member Avatar for Salem
0
129
Member Avatar for cernette

Alas, your program now can't read a file in dynamic or static arrays. See: [code=cplusplus] string line; ifstream data(fName); // Determine number of lines in file int nLines = 0; /* *** You count eof too (no this line but nLines++...) while (!data.eof()) { // string line; // *** move …

Member Avatar for ArkM
0
109
Member Avatar for JaR

Nothing criminal with VC++ 2008. Are you sure that the snippet corresponds to the real context? What a compiler are you using? Some tip-comforter - use typedefs in templates: [code=cplusplus] template <class T> class CSplit { typedef std::list<std::vector<T> > ListVector; private: ListVector m_Events; public: bool Event (int Channel, int Message); …

Member Avatar for JaR
0
116
Member Avatar for kwesicat

1. I don't understand where the problem starts. You have else without previous if. 2. There are some suspicious fragments in your code. For example, in geoParaFunc you allocated three arrays (see Para... pointers) then overwrite these pointers in [code=cpp] ... Para=geoParaFunc(atNumb[i],Zeq); // function call ... [/code] It's classic memory …

Member Avatar for kwesicat
0
115
Member Avatar for coveredinflies

1st part additions: all these chars are control codes for hard copy consoles. Most of them works now (how funny! nostalgic speaker beep after \a). However "\r\n\t" triad is fully actual... 2nd part: it seems STLFilt is potentially useful tool. C++ template diagnostic messages look like nightmares, it's true. Try …

Member Avatar for Duoas
0
119
Member Avatar for arun_lisieux

What compiler are you using? I can't see any error messages in your post. Why [icode]int pointVal (string s)[/icode] and where is [icode]int HowEasy::pointVal(string s)[/icode] MEMBER FUNCTION definition? Probably, it's a reason of your troubles...

Member Avatar for ArkM
0
252
Member Avatar for Corum

Use magical word virtual in [code=cplusplus] class rotatableList { ... virtual void rotate () ... ... }; [/code] and try again...

Member Avatar for Corum
0
133
Member Avatar for Sana nawaz

Are you sure it's the right place where lazy pupils engage project teams for free of charge?

Member Avatar for VernonDozier
0
148

The End.