1,296 Posted Topics
Re: [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 … | |
Re: Use [icode]else if[/icode] instead of several ifs in the loop. Why you check redundant conditions after if (... true ...)? | |
Re: Use std::wifstream, std::wofstream and other w..streams - streams of wchar_t elements. | |
Re: That's true if not counting monstrous MS NET "extensions" for "managed" codes... | |
Re: 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. | |
Re: 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() … | |
Re: Cool! I have never seen a man who is ready to use ATM which sometimes pays out money but sometimes plays music only... | |
Re: 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 … | |
Re: 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] ? ;) | |
| |
Re: Better you provide us with the code and we help to debug it... | |
Re: 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, … | |
Re: 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... | |
Re: 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 … | |
Re: 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] ;) | |
Re: 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? | |
Re: 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 … | |
Re: Well, any XHTML doc is a well-formed XML doc too. Try any XML parser (expat, libxml or others)... | |
Re: Practically all modern DBMS (may be except some OODBMS) have C interfaces (direct or via ODBC). Try MySQL, for example... | |
Re: 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... | |
Re: 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 … | |
Re: 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 … | |
Re: [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. | |
Re: [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, … | |
Re: 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: … | |
Re: [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]] = … | |
Re: 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 … | |
Re: 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 … | |
Re: How funny: you get double input then use INTEGER arithmetics with int variables... That's all, guy... | |
Re: 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 … | |
Re: 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... | |
Re: 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 … | |
Re: 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 … | |
Re: [url]http://www.daniweb.com/forums/thread148080.html[/url] 11 days ago, not in a galaxy far far away but on DaniWeb forum ;).. | |
Re: 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: … | |
Re: 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 … | |
Re: 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 … | |
Re: 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! | |
Re: [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 … | |
Re: [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 … | |
Re: 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... | |
Re: 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 … | |
Re: 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?.. | |
Re: 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] … | |
Re: 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. | |
Re: 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] | |
Re: Yet another tip: you can get "mirrored" char with only one and a very simple expression without any explicit numbers... | |
Re: It's absolutely senseless operation to write memory addresses (pointer values) onto external files. Addresses are not persistent values... Better reread your task specifications... | |
Re: 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++. … | |
Re: 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... |
The End.