1,296 Posted Topics

Member Avatar for wislean

Ooh, yet another grade supersystem... Better try to search DaniWeb for [i]grade[/i]. There are lots of dozens of grade calculation threads (solved;))...

Member Avatar for csurfer
0
163
Member Avatar for gplkrsna

Of course, it's possible (under your program "manual" contol). Open file in binary mode. Use fread and fwrite function. See fseek library function to set current write position and ftell to get it.

Member Avatar for csurfer
0
100
Member Avatar for jeremyg
Member Avatar for jephthah
0
168
Member Avatar for daino

There is freeware Qt for Windows now (from April 2009). There are some other freeware GUI libs for Windows - as usually, they are portable too.

Member Avatar for Prabakar
0
275
Member Avatar for adarshcu

More precisely: [i]if the program attempts to modify an array corresponding to a string literal, the behavior is undefined[/i].

Member Avatar for adarshcu
0
71
Member Avatar for TheBattlizer

Try to understand the standard compilation process logic. Simplified translation process description: 1. Every .cpp file is processed separately (as if no other cpp files) 2. Preprocessor stage: process all # directives. Every active (see AD's post, #ifdef/#ifndef directives) #include directive in .cpp file is replaced by referred .h (or …

Member Avatar for ArkM
0
2K
Member Avatar for Kev06N
Member Avatar for DinMan

[QUOTE=DinMan;881993]Hi! I would like to print a text file having some records onto the screen while running my program. Can sumone suggest me the easiest way to do it. I know I have to open the file using fopen() then what...[/QUOTE] Can you put more specific question? How to... - …

Member Avatar for Aia
0
91
Member Avatar for TheBattlizer

Place your struct type definition in .h file: [code=cplusplus] struct Points { int xCoordinate; int yCoordinate; int zCoordinate; }; ... global functions prototypes [/code] Include this .h file in all modules (.cpp files) where Points type needed (in the main file too). Change array point declaration to [code=cplusplus] // main …

Member Avatar for TheBattlizer
0
142
Member Avatar for vs.vaidyanathan

Step by step instruction: 1. Start Visual Studio 2. Select Help | Index 3. Type LNK2001 in Look For field 4. Click on LNK2001 list element 5. Read about LNK2001 error 6. Error correction: obvious after steps 1-5 About LNK1120: 7. Close Visual Studio 8. Do the same procedure as …

Member Avatar for vs.vaidyanathan
0
122
Member Avatar for bolx

Keep it simple: [code=cplusplus] for (int i = 12; i; i--) cout << i << " times 3 = " << 3*i << '\n'; [/code] ;)

Member Avatar for Kev06N
0
145
Member Avatar for bhagyaraj

See: you have [b]fac > no[/b] for all [b]no[/b] values because fac = n!. Therefore [b]no/fac == 0[/b] (integer division) and com=com+j is the same as com += 0... 1. Use [b]double[/b] type for math calculations (not float). 2. Use floating-point division if you want to get floating-point result, for …

Member Avatar for bhagyaraj
0
197
Member Avatar for vs49688

1. By the way, you must define non-trivial copy constructor and assignment operator for this class String (or declare them as private to prevent inevitable program crash if default copy constructor and/or assignment will be called). 2. If you want String to std::string conversion, define it, what's a problem? [code=cplusplus] …

Member Avatar for ArkM
0
316
Member Avatar for hetngay

What's a monstrous post! Have you ever seen this forum rules? [url]http://www.daniweb.com/forums/announcement8-2.html[/url] [url]http://www.daniweb.com/forums/announcement8-3.html[/url] [noparse][code=cplusplus] source [/code][/noparse] Have you ever tried to read this awkward jumble of a third-party code?

Member Avatar for Ancient Dragon
0
156
Member Avatar for kostasxx

Good programmers are capable to write more effective programs practically in any programming languages than bad programmers can do it in machine codes ;)

Member Avatar for vs.vaidyanathan
0
200
Member Avatar for monkey_king

It's so easy: [code=cplusplus] typedef std::map<const char*,int,cmp_str> Map; void cleanup(Map& m) { for (Map::iterator i = m.begin(); i != m.end(); i++) free(const_cast<char*>(i->first)); m.clear(); } [/code] Be careful: this map must have keys allocated by C-functions strdup or malloc.

Member Avatar for ArkM
0
2K
Member Avatar for yashyash

I have created dummy text file like OP source (~572 Mb, 40000000 lines) then converted it to binary form with VC++ 2008 for ~3.5 minutes without special buffer control. That's OK, no problems. 1. Open both files in binary mode. 2. Inspect source file with hex editor. Probably it's corrupted. …

Member Avatar for Ancient Dragon
1
182
Member Avatar for killdude69

Keep it simple: [code] fileName[0] = '\0'; // or even *fileName = 0; // to test: if (*fileName) { // non-empty [/code] ;)

Member Avatar for killdude69
0
383
Member Avatar for Daria Shmaria

It's legal to [b]compare[/b] any pointer value with null pointer or any others pointer values of the same type. Better post your code fragment with segmentation fault. It's annoying to download the whole source, didn't you understand it?

Member Avatar for ArkM
0
460
Member Avatar for abhishek2301

OP solution: [code=cplusplus] inline // interval [0..1) double drand() { return ::rand()/(RAND_MAX+1.0); } inline int randincr(int& counter, double p) { return drand() < p? ++counter: counter; } [/code]

Member Avatar for ArkM
0
140
Member Avatar for Ameerah

Probably the best method to build name list dictionary is: 1. Define std::map<std::string,unsigned> (dictionary name-counter) 2. Read names and insert them into the map (increment name counter if the name is in the map) 3. Traverse map with iterator: you will get an ordered ([i]automatically[/i];))name list with counters. If the …

Member Avatar for ArkM
0
198
Member Avatar for gretty

Keep it simple and effective: [code=cplusplus] const std::string& DayOfWeek(int dow) { static const std::string day[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "???" }; return day[dow < 0 || 6 < dow? 7: dow]; } [/code]

Member Avatar for ArkM
0
127
Member Avatar for Daria Shmaria

You didn't include <string> header in main.cpp (for std::getline declaration). Change "iostream" and "fstream" to <iostream> and <fstream> (standard headers). You declare al variable in the if alternative block. Of course, this local variable is out of scope outside this block. Declare al at the main function body level - …

Member Avatar for Daria Shmaria
0
155
Member Avatar for lyardson

Try Google: [i]C++ Java comparison[/i] Are you sure that it's a question for a half-page forum answer?

Member Avatar for mirfan00
0
280
Member Avatar for Massena

May be you still remember (from a school math course) that no fractions which are equal to pi number. Other post correction: double type provide ~16 decimal digits precision (53 bits of mantissa).

Member Avatar for ArkM
0
121
Member Avatar for hodge-podge

I was trying to understand what's [i]the ASCII value of a string of text[/i] (about 10 seconds or even more)... Alas... Can you explain what is it? Now I see why you [i]cannot seem to figure out how to convert the text into an ASCII value[/i]. However if you want …

Member Avatar for ArkM
0
149
Member Avatar for kylcrow

If you want to obtain hash index in a table of size B, don't forget: 1. Make [b]unsigned[/b] int calculations ([icode]x[i]-a[/icode] is signed value). 2. Result is sum % B. 3. As usually, no need to avoid integer overflow. May be better don't invent a square wheel? Are you familiar …

Member Avatar for ArkM
0
169
Member Avatar for ashishchoure

That's a well-known identity: [code] A and B <=> not (not A or not B) [/code] As far as I know there are [i]not[/i] and [i]or[/i] operators in all versions of regular expressions... Remark on post#2: string::find returns unsigned value. It's a bad practice to assign it to int variables …

Member Avatar for ArkM
0
340
Member Avatar for omarzia88

May be it helps: [url]http://www.ucancode.net/Free-VC-Draw-Print-gdi-example-tutorial/Free-VC-Draw-Print-gdi-example-tutorial.htm[/url] ?

Member Avatar for ddanbe
0
141
Member Avatar for manishgurnaney1

> Hi all, > I am using Visual Studio 2005, and developing some application. Currently i am facing one problem. I have written a class and declared some member variables in the class. In the constructor i am initializing the member variables to 0(member variable is int). But when i …

Member Avatar for ArkM
0
120
Member Avatar for madhavb

You (and me ;)) can't define member constructor parameters in the member declaration. Right solution: [code=cplusplus] class B { vector <A> a; int y; public: B():a(10) {} }; [/code] Apropos, erase semicolons after inline constructor definitions. >any idea... Read the language specifications more carefully ;)

Member Avatar for ArkM
0
74
Member Avatar for brightsolar

Please, post your code with code tag: [noparse][code=cplusplus] source [/code][/noparse] Read this forum announcement: [url]http://www.daniweb.com/forums/announcement8-3.html[/url]

Member Avatar for brightsolar
0
238
Member Avatar for sarawilliam

1. You may get 26-th character of readLine as [icode]readLine[26][/icode] - why [icode]sscanf(readLine+26...)[/icode]? 2. Check input line length: may be no 26-th character in the line... 3. Why 'b' in +26 position corresponds to branch instruction? May be it's 'b' in the comment line... 4. Why +30 position corresponds to …

Member Avatar for ArkM
0
106
Member Avatar for khenz

Other code defects: 1. Right copy constructor signature is: [code] NumberList::NumberList(const NumberList&); [/code] 2. What happens if you want to initialize new list with empty list? The right answer: memory access failure occured. No obj.head == 0 test in copy constructor. 3. You must define overloaded operator=() or make it …

Member Avatar for ArkM
0
4K
Member Avatar for atman

What's a problem? [code=cplusplus] for (i = 0; len <= 0 && str[i] || str[i] && i < len; i++) { cio_putch(str[i]); } while (i++ < len) cio_putch(' '); [/code]

Member Avatar for ArkM
0
325
Member Avatar for rukunaditya

abhishekp is right, but not class only and not global only: [code=cplusplus] int main() {} // do nothing!!! static struct __ { __() { cout << "Hello..."; } ~__() { cout << "Bye!\n"; } } _; [/code]

Member Avatar for Narue
0
171
Member Avatar for FaMu

tux4life, don't torment the unhappy C++ programmer, tell him/her about [icode]while(f>>i)[/icode] construct ;)

Member Avatar for FaMu
0
167
Member Avatar for wnrqkflwnrqkfl

>By the way: where do you close that file ? File stream destructor closes that file. That's OK.

Member Avatar for Dave Sinkula
0
3K
Member Avatar for crazyluigi

Sorry, what did you want to achieve with this senseless subexpression: [icode](op!='e')^(op==256)[/icode]?

Member Avatar for crazyluigi
0
1K
Member Avatar for pxndx

[QUOTE=William Hemsworth;877116]How unfair! I bought that book once, I never knew it was on msdn. :P[/QUOTE] Don't worry, buy yet another book! ;)

Member Avatar for ArkM
0
147
Member Avatar for mysong

Well, and where is the conversion formula? Now you have a very profitable business (fixed 13.20 pesos for 10$, 100$ etc). Other code defects: 1. The second is_number parameter defines a number of chars to be checked. However the 1st argument is C string and it can be shorter than …

Member Avatar for mysong
0
392
Member Avatar for Brandon515

[icode]cout << r[0] << r[1][/icode] or [icode]cout << r.substr(0,2)[/icode] ;)

Member Avatar for Brandon515
0
115
Member Avatar for shuda009

It seems you don't understand my post in the recent thread where [i]Narue kindly gave you the answer[/i]: [url]http://www.daniweb.com/forums/thread194034.html[/url] There was your current problem solution in the code snippet. Probably you have a good chance to post your problem in loop forever manner ;)

Member Avatar for tux4life
0
178
Member Avatar for TheSeraph

About that X extraction: Find "var sessionId = " then extract RandomKey. The last operation depends on the RandomKey terninator (or the next field delimiter). For example, if RandomKey field terninator is a blank char ' ' it looks like: [code=cplusplus] const size_t none = std::string::npos; std::string key, varid("var sessionID …

Member Avatar for TheSeraph
0
80
Member Avatar for shuda009

1. here's this forum announcement: [url]http://www.daniweb.com/forums/announcement8-3.html[/url] [noparse][code=cplusplus] source [/code][/noparse] 2. See an example of these cmds parsing: [code=cplusplus] // don't forget to include <sstream> typedef istringstream::pos_type Pos; // cmd arg parsing sample only: void cmdGet() { string line, cmd, arg; bool intarg = false; int iarg; cout << "Type instruction: …

Member Avatar for shuda009
0
453
Member Avatar for headacheinC

Of course, you have linker error because nobody (except you) knows such library function as [i]concat[/i] (probably you want strcat). The second attempt failed because fgets function puts the last '\n' character in the buffer (read library function specifications more carefully): [code] Input buffer after successful fgets: <line contents><'\n'><'\0'> [/code] …

Member Avatar for headacheinC
0
590
Member Avatar for Raven6666

Avoid [icode]while (file.eof()) {...}[/icode] loop condition, it's a wrong pattern. Check file.eof() AFTER an input operation only. [code=cplusplus] ifstream file(filename); int n = 0; string line; while (getline(f,line)) { // Now you have a line! n++; } [/code] The simplest way to test C++ stream state: [code=cplusplus] if (!file) { …

Member Avatar for Raven6666
0
137
Member Avatar for zack.walters

>what is array of void and why am I getting it in the following program? >I cannot figure out what this array of void is. Don't worry: nobody knows what's an array of void because no such animal in C and C++ languages ;)

Member Avatar for ArkM
0
140
Member Avatar for Abbygail

1. Wrong reallocation in CStack::push. You must assign new memory block pointer value to the bottom_ pointer (see realloc specification carefully). Now you have memory corruption after realloc call. However it's wrong method to reallocate memory obtained by operator new with C library function realloc. Avoid using malloc, calloc and …

Member Avatar for ArkM
0
284
Member Avatar for newbiecoder

>I wrote this code, but it didn't change anything You can't [b]compile[/b] this code, that's why it didn't change anything: the [b]else[/b] alternative has no correspondent if! Didn't you see it? What did you want to achieve with so strange [icode]a[i] == 8 || a[i] == 9[/icode] condition? It's a …

Member Avatar for ArkM
0
118

The End.