1,296 Posted Topics

Member Avatar for johnray31

[code=c] char * x ="vipin"; [/code] Now the pointer x refers to the char array {'v','i','p','i','n',0} representing the string literal "vipin". String literals are constants and placed in read-only memory pages (on all modern systems). Regrettaby, C forbid to overwrite literals but it's not a sematics error to declare non-constant …

Member Avatar for ArkM
0
126
Member Avatar for jgelderloos

Use [icode]else if[/icode] instead of several ifs in the loop. Why you check redundant conditions after if (... true ...)?

Member Avatar for cikara21
0
198
Member Avatar for amerninja2
Member Avatar for NekoGráfico
0
118
Member Avatar for cooljeff1379

That's true if not counting monstrous MS NET "extensions" for "managed" codes...

Member Avatar for kux
0
386
Member Avatar for jems000

Use BGIOBJ utility to convert BGI drivers and fonts to obj files and link them with your program. Read UTIL.DOC help file. BGIOBJ and UTILL.DOC files are in the TC installation directory.

Member Avatar for jems000
0
156
Member Avatar for monogana

I don't like this approach, but... [code=cplusplus] template <typename C> typename C::iterator SlowFind(C& c, const typename C::value_type& v) { typename C::iterator i; for (i = c.begin(); i != c.end() && *i != v; ++i) ; return i; } typedef std::vector<int> Vector; typedef std::list<int> List; using std::cout; using std::endl; int main() …

Member Avatar for monogana
0
174
Member Avatar for jhuyenh

Cool! I have never seen a man who is ready to use ATM which sometimes pays out money but sometimes plays music only...

Member Avatar for ArkM
0
215
Member Avatar for gangsta gama

1. Fixed (not scientific) notation, no fractional part: [code=cplusplus] #include <iomanip> ... cout << fixed << setprecision(0) << pow(Ex,Ey) << endl; [/code] 2. Use double for Ex. Ey, Sx, Sy. Declare these variables locally (in functions), no need in global scope. Don't capitalize ordinal variable names... 3. Delete all irrelevant …

Member Avatar for ArkM
0
170
Member Avatar for aksshe10

Well, now you have stopped to play a role of an inspired researcher... How about this orphan thread: [url]http://www.daniweb.com/forums/announcement118-2.html[/url] ? ;)

Member Avatar for aksshe10
0
133
Member Avatar for jillcatrina
Member Avatar for ArkM
0
102
Member Avatar for localp
Member Avatar for ArkM
0
35
Member Avatar for paynegm

1. Where is the closed brace terminated swap function body? 2. Use code tag properly: [noparse][code=c] ... snippet ... [/code][/noparse] 3. Keep it simpler (avoid index minus offset where possible): [code=c] for (j=0; j<i; j++) { if (h[j] > h[j+1]) { [/code] 4. Think about swap call arguments: pass pointers, …

Member Avatar for ddanbe
0
111
Member Avatar for aksshe10

If your vulnerable data are not encrypted it does not matter where you hide passwords or user names... If data are encrypted then generate dechipher key from a user input - no need to hide anything in that case, let intruder breaks his/her brains...

Member Avatar for ArkM
0
105
Member Avatar for niketan

Of course, max queue capacity (more precisely, underlying container class max capacity) depends on STL implementation. I can't imagine that any 32-bit (or 64-bit) STL deque (queue default container) has less than billion (or near) items capacity... Search your platform forums on possible STL version implementation defects. It seems that …

Member Avatar for ArkM
0
109
Member Avatar for abrou

Yes, he/shi did... February 2008: [url]http://www.qtcentre.org/forum/f-newbie-4/t-error-expected-class-name-before-token-12015.html[/url] ;)

Member Avatar for ArkM
0
298
Member Avatar for DevC++4.9.9.2

Well, your Check function does not return value after self-recursive call (see the last statement w/o return). Didn't MinGW compiler diagnose this obvious error?

Member Avatar for ArkM
0
90
Member Avatar for jakethesnake86

It's so simple: you pass your debugger by value (see step function signature). So step works with copy of debo (another debugger object!), debo var was intact... Pass it by reference: [code=cplusplus] void step(char* file, string data, debugger& debo) [/code] It seems better solution is to define register file of …

Member Avatar for ArkM
0
128
Member Avatar for Nalini Ramesh

Well, any XHTML doc is a well-formed XML doc too. Try any XML parser (expat, libxml or others)...

Member Avatar for ArkM
0
35
Member Avatar for serkan sendur

Practically all modern DBMS (may be except some OODBMS) have C interfaces (direct or via ODBC). Try MySQL, for example...

Member Avatar for ArkM
0
72
Member Avatar for newbie5150

What's a gibberish text after the last if! What a language are you using? It's not C++. Moreover, it's not C# or Basic or. Next time copy/paste someone else's code more accurately...

Member Avatar for mrboolf
0
144
Member Avatar for empathy

At first you must load map contents (where is the code? ). But you have another problem: [icode]std::map<char*,int>[/icode] can't help you because its key_type is char* but operator< for char* type compares pointer values, not referred C-strings. Therefore you will get wrong dictionary... It's possible to define a simple wrapper …

Member Avatar for kux
0
225
Member Avatar for Villanmac

I think that embedded software topics are not relevant for DaniWeb type forums. It's a very interesing but too specialized area. As usually, no common programming language problems there. See your problem, for example: you need help on the particular device programming (ports, time-outs etc). Better ask the question on …

Member Avatar for skatamatic
0
191
Member Avatar for mrtwinkles

[quote]...though you'll have to change the string to a character array to do that[/quote] Nope. You can use [icode]operator[][/icode] to access chars in std::string directly.

Member Avatar for DemonGal711
0
218
Member Avatar for DemonGal711

[quote]and then says that the program has stopped working and needs to close[/quote] Who says that? Where's the message text? Is it OS message? If so - as usually the memory is corrupted before this point. Obviously the problem is not in this relatively simple (but questionable - for example, …

Member Avatar for DemonGal711
0
123
Member Avatar for Helgso

It seems we can't "just pass "." as the first argument": the current directory does not bear a relation to the executing module directory. Use GetModuleFileName Windows API function to "retrieve the full path and filename for the executable file containing the specified module": [code] // Windows Platform SDK needed: …

Member Avatar for Helgso
0
2K
Member Avatar for M00nDancer

[code=cplusplus] int main() { vector<int> positions; list<char> letters; ifstream file("phrases.txt"); string line; list<char>::iterator c; size_t i; while (getline(file,line)) { positions.clear(); letters.clear(); for (i = 0; i < line.length(); ++i) if (isalpha(line[i])) { letters.push_back(line[i]); positions.push_back(i); } letters.sort(); for (i = 0, c = letters.begin(); c != letters.end(); ++c, ++i) line[positions[i]] = …

Member Avatar for M00nDancer
0
148
Member Avatar for muya08

Chapter 2 of the C++ Standard defines C++ preprocessor functionality: [quote]...If a source file that is not empty does not end in a new-line character, or ends in a new-line character immediately preceded by a backslash character before any such splicing takes place, the behavior is undefined.[/quote] It's the other …

Member Avatar for Ancient Dragon
0
72
Member Avatar for afromong

Alas, ddanby's "solution" is absolutely incorrect. Must be [code=cplusplus] if (scanf("%d",&i) == 1 && i > 0) { // OK ... } else { // error or eof or <= 0 [/code] If you have a C-string str with text, test if it's an integer: [code=cplusplus] if (sscanf(str,"%d",&i) == 1 …

Member Avatar for afromong
0
86
Member Avatar for atman

How funny: you get double input then use INTEGER arithmetics with int variables... That's all, guy...

Member Avatar for Aia
0
145
Member Avatar for skatamatic

The C++ is a platform-independent universal programming language. No such entities as "processes stack or something" in platform-independent languages. Of course, you can implement any desired code in C++, but (alas): prepare to get "extensive knowledge of windows classes/programming" before start your insolent project (probably it's a right way to …

Member Avatar for zhouxuzhu1985
0
148
Member Avatar for JackDurden

At first define position specifications. For example, what's a position for inexistent item value? What's a position of the 1st node - and so on...

Member Avatar for skatamatic
0
105
Member Avatar for blackslither

It's a slightly strange statement that "the complexity is O(n^6)". A Life2d cell has 8 neighbours. A Life3d cell has 26 neighbours - that's all. Help to optimize - what? That is a question... Look at some prompts in http://en.wikipedia.org/wiki/Conway's_Game_of_Life Search Google for sparse matrix implementations... Try to link all …

Member Avatar for ArkM
0
91
Member Avatar for kotkata

Of course, you have a problem with incorrect function header. You must declare parameter list in the header: [code=cplusplus] void displayBoard (int board[][COLS], int rows, int reveal[][COLS], int whatelse) ... [/code] Have you ever seen C++ syntax description? Don't mix function call expression with function header!.. Additionally you have erroneous …

Member Avatar for ArkM
0
181
Member Avatar for k88joshi

[url]http://www.daniweb.com/forums/thread148080.html[/url] 11 days ago, not in a galaxy far far away but on DaniWeb forum ;)..

Member Avatar for ArkM
0
88
Member Avatar for andrewama

Some notes about your class design: 1. It's extremely ineffective way to pass huge size arguments by value. Use references: [code=cplusplus] ... IntegerSet unionOfSets(const IntegerSet& s2) const; ... [/code] Don't forget to declare const where it's a semantically possible solution. 2. You write a code in C++. Use bool type: …

Member Avatar for grumpier
0
169
Member Avatar for ragaven

The only standard way to validate file path is: try to open the file. [code=c] int isFilePath(const char* fname) { int ok = 0; FILE* f; if (fname && (f=fopen(fname,"r") != 0) { fclose(f); ok = 1; } return ok; } [/code] Regrettably there are lots of cases when open …

Member Avatar for Ancient Dragon
0
342
Member Avatar for chetoos

Probably the simplest way to adopt your selectionSort for int arrays function code is as follows. Look at the function code. There is temp variable of a sorted array base type (to swap elements). There is a compare ints expression in the loop. And, of course, there is a sorted …

Member Avatar for ArkM
0
117
Member Avatar for at51178

Why socket programming for indexing of files on a network drive?.. Better search inet on this topic. I think it's a project for some years of hard work... Good luck!

Member Avatar for Freaky_Chris
0
69
Member Avatar for Th3_uN1Qu3

[code=cplusplus] if (AddFontResource(myFont) == 0) { // Alas... YOU know what to do in that case... } [/code] As far as I know it's possible to define several filenames in the argument string ( | separated names). In that case you know how many font files needed so you can …

Member Avatar for Th3_uN1Qu3
0
96
Member Avatar for coolbuddy059

[quote]...we must perform the operation DISK-READ(x) to read object x into main memory before we can refer to its fields. (We assume that if x is already in main memory, then DISK-READ(x) requires no disk accesses; it is a "no-op.") Similarly, the operation DISK-WRITE(x) is used to save any changes …

Member Avatar for ArkM
0
142
Member Avatar for jhuyenh

Well, it's clear that you don't understand you homework... And we don't understand what's your problem too... Why two files? What's a relation between function protorypes and arrays? What's your encode (decode) method(s)? And so on...

Member Avatar for ajay.krish123
0
429
Member Avatar for n8thatsme

Fortunately, it's so simple: ;) [code=cplusplus] cin.ignore('\n'); // skip 10 chars: '\n' == 10 [/code] The 1st ignore() member function argument: The number of elements to skip from the current read position. That's why you have "or the engine" wreck only. Change to [code=cplusplus] cin.ignore(1,'\n'); [/code] or study the Narue's …

Member Avatar for seanhunt
0
164
Member Avatar for rock_climbr

Well, a little counter-question: I have my code working for all test data sets. Suddenly yesterday (or this evening) it was crashed. It seems it does not work properly. Any ideas? Can you help me?..

Member Avatar for ArkM
0
110
Member Avatar for cicigirl04

Yet another tip. There is a wonderful class valarray in C++ STL. It lives in (undeserved) obscurity. If you declare your array as a valarray, for example: [code=cplusplus] std::valarray<int> a(10); [/code] and fill it from the console (as an usual array), you may use its member functions, for example: [code=cplusplus] …

Member Avatar for DaJoker
0
283
Member Avatar for cam875

Yes, it is, but it's not a reference, it's a pointer to the 1st element of a vector contents (until you invoke any op changed vector's size or capacity). The C++ Standard guarantees that std::vector contents occupies contiguous and properly aligned memory area.

Member Avatar for cam875
0
110
Member Avatar for blackslither

Parameters passed by value in C, so your change function does nothing: it change its local copy of x parameter but not xx argument. Define then use this (slightly strange) change function as follows: [code=c] void change(int** x, int* y) { *x = y; } ... change(&xx,yy); ... [/code]

Member Avatar for Aia
0
146
Member Avatar for Gagless

Yet another tip: you can get "mirrored" char with only one and a very simple expression without any explicit numbers...

Member Avatar for Freaky_Chris
0
305
Member Avatar for ambarisha.kn

It's absolutely senseless operation to write memory addresses (pointer values) onto external files. Addresses are not persistent values... Better reread your task specifications...

Member Avatar for ambarisha.kn
0
203
Member Avatar for idontexist

Better write a single function to get operands of a binary operation. Now you have tons of redundand repetitive codes. It's a bad style ;). Remember one of the most valued programming principles: divide and power ;)... I agree with Freaky_Chris: no problems with integer division in C and C++. …

Member Avatar for idontexist
0
309
Member Avatar for Villanmac

These code scraps look like a part of an attached (to microcontroller, for example, M16C) device ( LCD? ) initialization routine written in extended C ( IAR? )... Get the compiler manual and the device data sheet for details... It's not C or C++ issue...

Member Avatar for ArkM
0
229

The End.