156 Posted Topics

Member Avatar for handytxg

You can look all that info up in a STL List reference, as the one found here: [url]http://www.cplusplus.com/reference/stl/list/[/url] See the "STL Algorithms" for sorting data inside STL containers.

Member Avatar for handytxg
0
179
Member Avatar for Clockowl

My goal is to create a program that plays Mahjong. I figured the algo would be a bit like this: [code] While there are blocks left { Fetch new board Recognize blocks //find 2 of the same images within the image. Find free blocks //not *really* necessary: computer versions don't …

Member Avatar for tux4life
0
183
Member Avatar for blerina12

So, what doesn't work? edges.open(); ? Double check the filepath please, hehe. Code looks okay, you won't need to clear it, unless errors occurred and you've recovered from them (or just want to reset them of course).

Member Avatar for blerina12
0
209
Member Avatar for halfnode

[quote=halfnode]is it possible to put a constructor into an array?[/quote] Yes, take a look here for an example: [url]http://www.daniweb.com/forums/post847675-7.html[/url] The size specifier for the array (base* [[b]3[/b]]) is not necessary, but it will make sure the array is of size 3 of course.

Member Avatar for siddhant3s
0
147
Member Avatar for bit9435

Header files such as string need to be included in the header file and in the .cpp file. We call these 2 files (header and .cpp) the definition of a class and its implementation when used to form a class. If you want more help, ask more questions, but try …

Member Avatar for Clockowl
0
108
Member Avatar for halfnode

[code=cpp] while(!inFile.eof()) { // use getline to read entire line getline(inFile, s); cout << s << endl; }[/code] That's wrong code. eof gets set when it has read eof, so and in that case getline() won't do a thing, so you'll output the last output twice (possibly). Correct code: [code=cpp] …

Member Avatar for halfnode
0
194
Member Avatar for scarebyte

[code=cpp]class Client { public: string name; Menu order; int table_number; string type; double bill; Client(void) { name=""; table_number=0; type=""; bill=0.0; } }; [/code] This code lacks the virtual addClient table wants to use. Another note: is a table a client? If not, you shouldn't have inheritance, but perhaps composition.

Member Avatar for scarebyte
0
767
Member Avatar for lancevo3
Member Avatar for lancevo3

So this should not be in a loop? [code=cpp] for (char *p = a; p!= fixPtr; p++) { *p=toupper(*p); }[/code] Why not do something like: [code] Set first letter to uppercase. Rest to lowercase [/code] with [code=c] void fixAddress ( char *a ) { a[0] = toupper(a[0]); for (int i …

Member Avatar for lancevo3
0
214
Member Avatar for danishamman

Oh hey look, it's free knowledge! [url]http://en.wikipedia.org/wiki/Sorting_algorithm[/url]

Member Avatar for jephthah
0
225
Member Avatar for camonchain

So, you know what you have to do, do it. :) [code=cpp] class invoice { ... }; [/code] Something like that.

Member Avatar for jephthah
0
190
Member Avatar for soulbee1

[code=c] const int MAX = 13; int a[MAX]; for (int i = 0; i < MAX; ++i) a[i] = i; for (int i = 0; i < MAX; ++i) { int r = rand() % MAX; while(r == i) r = rand() % MAX; int t = a[i]; a[i] = …

Member Avatar for nucleon
0
730
Member Avatar for dulahdaglace

Hurr, it might be a really stupid "error". One time (at band camp, xD) I was trying to open a file from an app I wrote in Code::Blocks on windows. So I put that file in project/bin/debug/, but code::blocks launched it in project/, so it couldn't find the file. Try …

Member Avatar for dulahdaglace
0
243
Member Avatar for Clockowl

Hey guys, How do you handle exceptions in your programs? For instance, I have this function: [code=cpp]bool load_file(const char *filepath, std::string &dest) throw (std::bad_alloc, std::runtime_error) { using namespace std; ifstream file; file.open(filepath, ios::binary); if (!file.good()) { throw runtime_error("Couldn't open the file"); } //get filesize in bytes from ifstream //seek end, …

Member Avatar for Clockowl
0
104
Member Avatar for TuX4020

If you're standing in queue line at the grocery shop, does the LINE look like a tree, with intersections and such, or more like an array of (possibly annoyed) customers? I sure hope it doesn't look like a tree.

Member Avatar for jrw0267
0
135
Member Avatar for LucyB
Member Avatar for blamp

So, what doesn't work? Check here for more info on templates: [url]http://www.cplusplus.com/doc/tutorial/templates/[/url]

Member Avatar for Clockowl
0
122
Member Avatar for moiron

Give it a shot here: [url]http://www.cplusplus.com/doc/tutorial/[/url] When you're stuck on a tutorial, you can ask for help of course.

Member Avatar for jephthah
0
105
Member Avatar for f.ben.isaac

[quote=MrSpigot]main() is just reading it, so no protection is necessary in this case.[/quote] That's wrong, almost 100% sure, couldn't make sure with google, but it's just 2 threads trying to access the same memory: doesn't matter if they read or write, both will lead to errors. Agreed on not using …

Member Avatar for Clockowl
0
150
Member Avatar for cause&effect

It's a slash in (/code), not a backslash. But A for effort. :D And you can supply the language as well, (code=cpp) Your code looks okay, but it looks a lot like C: it's not using OOP. Which would be a nice approach for a board game. My output looks …

Member Avatar for Clockowl
0
88
Member Avatar for Niner710
Member Avatar for ArkM
0
123
Member Avatar for JohnKeays

If your coding C, why post in the C++ forum? Anyway, show some code. A quick google gives me this: [url]http://weseetips.com/2008/08/27/how-to-set-color-for-static-control-text-in-dialog/[/url] and [url]http://www.programmersheaven.com/mb/mfc_coding/147975/147975/how-do-you-change-static-text-box-text-color/?S=B20000[/url] Don't know if they are addressing your problem.

Member Avatar for nucleon
0
87
Member Avatar for pt_solar

What doesn't work? new doesn't set the allocated memory to 0, could that be a problem? Be a bit more specific please.

Member Avatar for Clockowl
0
2K
Member Avatar for Gerlan

char *file? If you're using fgets(), I'm guessing it wants a C-style FILE *. ;) Anyway, you're in C++ land now, try getline() or something like that. Safer, easier. Other then that, the code is kinda.. bad.. You've a loop that fetches data from the ifstream into your char array, …

Member Avatar for Gerlan
0
122
Member Avatar for Clockowl

Hey guys, How do I disable/get rid of that default exception message windows shows when you have an "unhandled" exception in your program? Here's my example code (sorry for not limiting the code's size to the problem only, it's readable enough I think): [code=cpp] #include <iostream> #include <fstream> #include <string> …

Member Avatar for Clockowl
0
163
Member Avatar for rudolph2004

Create an array/vector of the struct (or pointers to), iterate it, compare the member variables to what you are looking for.

Member Avatar for rahul8590
0
81
Member Avatar for Clockowl

Hey guys, I've this code: [code=cpp] #include <iostream> #include <fstream> #include <sstream> #include <string> using namespace std; bool load_file(const string &filepath, string &dest){ ifstream file; file.open(filepath.c_str(), ios::binary); if(!file.good()){ cerr << "Fatal error while opening file." << endl; return false; } //get filesize in bytes from ifstream //seek end, get pointer, …

Member Avatar for Clockowl
0
996
Member Avatar for lionleo

Well lionleo, welcome to Daniweb: where we don't code homework assignments for others. :D What's the problem? Do you know how to read in a file? Grab lines from that file? Parse those lines?

Member Avatar for ithelp
0
77
Member Avatar for ejiroy

[code=cpp]void Employee::set(double payRate, int hours) { cin >> payRate; cin >> hours; }[/code] Change that to... [code=cpp]void Employee::set(double payRate, int hours) { this->payRate = payRate; this->hours = hours; }[/code] I'm not guarranteeing that it works on every compiler, but I think it should. If you don't understand the code, let …

Member Avatar for VernonDozier
1
91
Member Avatar for pridathabah

The End.