1,296 Posted Topics

Member Avatar for jimbob90

[code=c++] inline char* Min(char* a, char* b, char* c) { return strcmp(a,b) < 0 ? strcmp(a,c) < 0? a: c : strcmp(b,c) < 0? b: c; } [/code] ;)

Member Avatar for ArkM
0
3K
Member Avatar for Jason123

Alas, you can't get desired effects with list<Vehicle>. The point is that std::list<Vehicle> container might save only Vehicle (base) part of an object, however you want to save not an abstract Vehicle but a Car object, a Bus object and so on. That's why virtual functions and abstract classes were …

Member Avatar for ArkM
0
90
Member Avatar for MosaicFuneral

[QUOTE=dougy83;746835]assuming str is of type 'string', str[i] is of type 'char'. chars will be considered negative whenever the top bit is set. It's not an issue if you are bitwise ORing, as you will get the correct result. If it annoys you, feel free to cast to unsigned char, as …

Member Avatar for MosaicFuneral
0
295
Member Avatar for rumencho

[QUOTE=rumencho;747039]Hi all. When I create simple console application with Visual Studio C++ ,and I run it, my program shows on full screen, How to adjust my .exe files to show on single console window?[/QUOTE] It's not .exe file issue. Change your windows installation command shell window properties. Look at [url]http://commandwindows.com/configure.htm[/url]. …

Member Avatar for ArkM
0
94
Member Avatar for Creator07

1. You never compare [icode] Name : Rose[/icode] with fgets'ed line because fgets appends '\n' to a line, so it looks like [icode] Name : Rose\n[/icode]. Solution: use strstr instead strcmp: [code=c] if (strstr(T,B[e])) { /* T found */ ... } ... [/code] 2. You are trying to copy FUTURE …

Member Avatar for devnar
0
109
Member Avatar for knharp3

1. The make5 is not a method, it's an ordinar function. Strictly speaking, no "method" term in C++. It's an informal alias for non-static member function. 2. Semantically a reference in C++ is another name of an object allocated in the memory (not only on the stack - moreover, no …

Member Avatar for ArkM
0
139
Member Avatar for mrboolf

1. Try to profile subset generator without any printing. There are ~1 million subsets (2^20) for N==20. To print 1 million lines... The program PRINTS all the time. 2. NextSubset code is obviously wrong: [icode]while(!Bitmask[i]&&i>=0)[/icode] refers to Bitmask[-1] at the last loop. Present all class Subset definition.

Member Avatar for mrboolf
0
744
Member Avatar for cristinel

I can't compile your code with VC++ 9 because it's an example of ill-formed C++ program. If you define (wrong) copy constructor with [icode]Vector<F>&[/icode] argument, it's impossible to initialize Vector<float> variable with Vector<double> initializator. The only possible way to do that is: 1. Convert Vector<double> object to temporary Vector<float> object. …

Member Avatar for cristinel
0
186
Member Avatar for SlayerX

911: [url]http://www.daniweb.com/forums/announcement8-2.html[/url] Sample code needed? Google is your friend!..

Member Avatar for Salem
-1
321
Member Avatar for JCasso

[QUOTE=JCasso;744426]Hi, I am programming a pos terminal by using C Programming language. I cannot use strtod() or atof (since it just calls strtod in it). Any advices on converting string to double without using these functions?[/QUOTE] Well, use sscanf. I think it's an incorrect question. Why pos terminal control program …

Member Avatar for ArkM
0
1K
Member Avatar for n8thatsme

1. You can't declare a vector of references in C++ (it's the other story why). Fortunately, I see a vector of POINTERS in you snippet. Feel the difference ;) 2. Why pointers in that case? Better define [icode]std::vector<SalariedEmployee>[/icode]. Take on trust: it's much more better for you ;) 3. What's …

Member Avatar for ArkM
0
373
Member Avatar for Momar

Yes, you are still fairly new to C++. The myp2 variable is a pointer to [icode]mypair<int>[/icode] so must be [code=cplusplus] cout << myp2->getVal() << endl; // pointer->member // or cout << (*myp2).getVal() << endl; [/code] The last code means: dereference pointer (get an object) then call member function for this …

Member Avatar for ArkM
0
89
Member Avatar for rmlopes

The template generation does not pay attention to executable statements in the template definition. The [icode]if (n > 0)[/icode] does not prevent recursive template bootstapping for [icode]GetNRands<0>, GetNRands<-1>[/icode] and so on. It's pity that VC++ can't detect this "instantiate forever" recursion. To break this recursion you may define this template …

Member Avatar for ArkM
0
138
Member Avatar for cog_bn

Reread the get member function specification more carefully. If [icode]cin.get(b,2)[/icode] can't obtain the next char from the cin, it sets failbit for cin. When the cin stream is in failed state, no more operations performed until you clear the cin state (by cin.clear(), for example). Now cin.ignore and cin>>... ignored …

Member Avatar for cog_bn
0
184
Member Avatar for Dannyo329

Don't waste a time for this nonsense. Download some ready-to-use keyboard sniffer and enjoy... For example: [url]http://3d2f.com/tags/keyboard/sniffer/[/url]

Member Avatar for BeyondTheEye
0
118
Member Avatar for ALAZHARY

[QUOTE=minas1;744460][B]result[/B] is a local variable, which is destroyed when the functions ends. So a garbage value is destroyed. The best solution is to do what is said by the poster above. If you need to work with pointers you can do this: [code=C++] double* treble(double data) { double result = …

Member Avatar for ALAZHARY
0
655
Member Avatar for VBNick

Some additions. I think a radix sort is not a suitable method to sort array of structures with sort key fields. You need a lots of additional memory and unnatural code modifications. Probably the simplest way to adopt common sort codes (usually published with int array parameter) for structures sorting …

Member Avatar for VBNick
0
179
Member Avatar for chunalt787
Member Avatar for chunalt787
0
181
Member Avatar for Nickyu0712

I see a very bad class design and implementation but no any compile-time errors ;)...

Member Avatar for Nickyu0712
0
335
Member Avatar for PieterN

It's not C++ language question. It's a question about YOUR compiler and linker. Read the compiler reference guide carefully, look at module map, try and see what happens - and so on...

Member Avatar for Salem
0
82
Member Avatar for T'Scoopz

1. Directly? You can't. But you can read word by word: [code=c] char word[32]; ... while (fscanf(f,"%31s",word) == 1) printf(">%c<\n",word[0]); /* that's the 1st char */ [/code] 2. You can't. Read line by line with fgets (or char by char with fgetc) then select ABCs explicitly.

Member Avatar for Salem
0
74
Member Avatar for kevintse

Totally unsafe: no null pointers check up at all. Strange operator= semantics. Right (common) operator= signature: [code=cplusplus] String& String::operator=(const String&); [/code] Try so natural p = q = s with your semantics ;) No useful string class methods (find, substr, individuall chars accessors etc). No operator <() - impossible to …

Member Avatar for ArkM
0
127
Member Avatar for sds234

Well, and what's your problem? May be better start from two wonderful ballades on this forum rules?.. [url]http://www.daniweb.com/forums/thread78223.html[/url] [url]http://www.daniweb.com/forums/announcement118-2.html[/url]

Member Avatar for StuXYZ
0
141
Member Avatar for Stepes

Are you sure that you really understand the difference between "declare" and "define" in C++? I think jencas was right and you don't DEFINE that constructor.

Member Avatar for Stepes
0
340
Member Avatar for Undermine

Keep it simpler, it's C++ now and here: ;) [code=cplusplus] #include <ctime> #include <cstdlib> #include <algorithm> ... srand((unsigned)time(0)); random_shuffle(deck,deck+52); // All done ;) [/code]

Member Avatar for StuXYZ
0
593
Member Avatar for egolovin

Qbasic is not a general purpose platform-independent language, it's a concrete implementation of Basic language dialect. No keyboard notion per se in the C++ language. There are lots of keyboard access functions and libraries in C++ implementations. What's your C++ compiler?

Member Avatar for ArkM
0
136
Member Avatar for Krysis

May be better stop this farce with rainbow coloured messages? It seems the (semi)professional forum is an area of communications but not a self-expresson... Have you ever seen the strtok C standard library function?

Member Avatar for Krysis
0
138
Member Avatar for kevintse

Read about: - pointers to member functions: [url]http://www.gidforums.com/t-18332.html[/url] - pointer to data members: [url]http://www.icce.rug.nl/documents/cplusplus/cplusplus15.html#l219[/url]

Member Avatar for ArkM
0
125
Member Avatar for Fouly

As far as I know you must use <iostream> and <fstream> headers and namespace std with Open Watcom C++ STL (incomplete) implementation (OWSTL) now. The old good WATCOM is a rather specific compiler. It seems the best place to get answers about OW peculiarities is OW community wiki and forum. …

Member Avatar for cikara21
0
190
Member Avatar for cutedipti
Member Avatar for ArkM
0
103
Member Avatar for Nemoticchigga

Have a look at the primary source: [url]http://www.keil.com/[/url] Of course, all Keil software tools are not freeware (one of the Product page headers: "Why Buy Tools From Keil?"). There are evaluation versions... Of course, it's the case where "Google is your friend", not DaniWeb...

Member Avatar for Colin Mac
0
103
Member Avatar for ajorge

Please, don't use this awkward combination of words as "Pointer Functions". No such beasts as "pointer functions" in C and C++. There are "pointer to function" types in both languages, there are correspondent values and variables. A pointer to function is a kind of POINTERS, not a kind of FUNCTIONS. …

Member Avatar for ArkM
0
119
Member Avatar for Whilliam

Is it so hard job to correct obvious errors: you get compiler messages on wrong function arguments: fread and fwrite want POINTERS to target/source data areas (&d - not d, &b - not b))! Use code tag properly: [noparse][code=c] source [/code][/noparse] Never use dangerous gets function: it does not check …

Member Avatar for Whilliam
0
248
Member Avatar for MacBarnes

The ofstream sorted is local in the recursive member function display so you are trying to open file stream on every function call and close it by the sorted variable destructor on every return from display. Obviously, it's absolutely wrong and senseless effect. There are two possible solutions. You may …

Member Avatar for cikara21
0
119
Member Avatar for fedderico10

As far as I know there is [code=c] int xmlStrEqual(const xmlChar * str1, const xmlChar * str2) [/code] function in xmlstring module (and other xmlChar string handling functions). For example, you can convert xml-string to ordinar C-string then use atol to get integer value of attribute - and so on... …

Member Avatar for Paul.Esson
0
2K
Member Avatar for haven_u

[url]http://www.edcc.edu/faculty/paul.bladek/Cmpsc142/matmult.htm[/url] ;)

Member Avatar for ddanbe
0
113
Member Avatar for solimanmuttawa
Member Avatar for ArkM
0
125
Member Avatar for rumencho

Sort chars? What for?!.. Can you explain what do you want to do with a file contents?

Member Avatar for ArkM
0
154
Member Avatar for bonnie1702

Not only destructor: d_addatbeg is wrong too (see empty list case)... Please, use code tag correctly: [noparse][code=cplusplus] source [/code][/noparse]

Member Avatar for ArkM
0
111
Member Avatar for JimD C++ Newb

Better use [code=cplusplus] std::ifstream file(...); std::string line; ... while (getline(file,line)) { ... } if (file.fail()) { // i/o error occured ... } [/code]

Member Avatar for JimD C++ Newb
0
202
Member Avatar for koushal.vv

Never, ever trust in database client program supplied "unique numbers". A well-designed database must have properly defined unique counter fields in its tables and/or correspondent database procedures/triggers. Let's forget home-made x-"databases" of 80-th ;)

Member Avatar for ArkM
0
146
Member Avatar for akira_shinizaki

You must detect bad input condition then handle it. If possible, make recovery. For example: [code=cplusplus] int x; cout << "Type integer: "; if (cin >> x) { cout << "Thank you..." << endl; } else if (cin.eof()) { // end of stream cout << "cin closed." << endl; } …

Member Avatar for ArkM
0
75
Member Avatar for OhItsThatGuy

1. If no majorIn member in a structure, why you wrote senseless and invalid expression [icode]student[i]majorIn[/icode]? It's simple majorIn argument! 2. What for you wrote the 1st if statement? You don't initialize i at that moment but refer to [icode]student[i][/icode]... 3. Why so strange form [icode]for(i=0;i<=n-1;i++)[/icode]? Keep it simpler: [icode]for …

Member Avatar for ArkM
0
264
Member Avatar for alex5161

It looks like an exam or test question ;) Well, it does not matter what's use function returned value: you forgot to initialize your c object ;)... Look at [url]http://www.daniweb.com/forums/announcement8-2.html[/url]

Member Avatar for ArkM
0
121
Member Avatar for valchid

[QUOTE=valchid;741719]and my tutor did say i can use gets or fgets so i dont know why he said it [/QUOTE] May be he is an inclined to sadism person. If so and if you are a latent masochist then use gets... ;)

Member Avatar for valchid
0
101
Member Avatar for Ahmed_I

You wrote a bunch of C-style unsafe functions instead of a good C++ class List with comfortable and safe interface. Look at the class std::list as a model. Now these templates look like a steam-engine with microcontrolled whistle...

Member Avatar for ArkM
0
197
Member Avatar for Fouly

You declare these member functions but forgot to define them. Probably, you define functions with such names without class name prefix, for example: [code=cplusplus] double GetRandomNumber() // Ordinar function { // does not bear a relation to the class ... } // You need double RandomVariableGenerator::GetRandomNumber() { ... } [/code] …

Member Avatar for Fouly
0
166
Member Avatar for psyman_86

1. Use code tags correctly: [noparse][code=c] source [/code][/noparse] 2. It's not a declaration only (with extern) for global variable: it's a very strange definition (with enormous macros currentpacketbeingsampled? or with macros xdata? ): [code=c] char xdata currentpacketbeingsampled; [/code] Never add definitions (except classes and templates in C++) in header files. …

Member Avatar for psyman_86
0
260
Member Avatar for Alex Edwards

Suppose one fine day (in year 1990, for example) the C++ Standard defines native binary data representations. Do you want 16-bit int now? How many long long longs are you ready to add in the future? An experienced and far-sighted software architect never relies on external data binary interfaces. There …

Member Avatar for ArkM
0
187
Member Avatar for MylesDBaker

[QUOTE=MylesDBaker;741808]Okay I figured out the default constructor. Now I need to create a function named "playerChoice" which changes the stored array value into whatever the player's space that is chosen and replaces it with an 'X' or 'O' and then calls a function to print out the current board status.[/QUOTE] …

Member Avatar for ArkM
0
151

The End.