Posts
 
Reputation
Joined
Last Seen
Ranked #440
Strength to Increase Rep
+8
Strength to Decrease Rep
-2
88% Quality Score
Upvotes Received
8
Posts with Upvotes
8
Upvoting Members
7
Downvotes Received
1
Posts with Downvotes
1
Downvoting Members
1
6 Commented Posts
~50.7K People Reached
About Me

Almost Uni Student.

Favorite Tags

156 Posted Topics

Member Avatar for somename

I don't get why you use fgets. If it's an ASCII file, and it should be for the thing you're trying to do, all you need to do is strstr(buff, find) and then memcpy. Not strcpy, in an ASCII file aren't any NULL bytes. Well, not that I know of. …

Member Avatar for deceptikon
0
3K
Member Avatar for JuliaCplus

Sorting any type of data with use of the STL: [url]http://www.cplusplus.com/reference/algorithm/sort/[/url] Which may be a bit too much for 3 strings, but you'll know how to sort 2000 too! :D

Member Avatar for NathanOliver
0
923
Member Avatar for omarelmasry
Member Avatar for homeryansta

[code=cpp] newnode = new Node; newnode = NULL; [/code] Eerrrr? That's a bit of weird code. You're trying to derefence that pointer on the next line! ;)

Member Avatar for sunn shine
0
178
Member Avatar for Clockowl

Hey guys, Here's my story: I had a HDD: Data, ~300GB I created a partition for another OS I'm done with the OS, remove the partition Now, it shows up as unallocated, and I can't find a way to merge it back to the drive it belongs to! A screenshot …

Member Avatar for Rik_
0
155
Member Avatar for jadedman

Here you go: [url]http://www.xmission.com/~nate/glut.html[/url] If you're on windows that is. Else, you need to download glut.h from somewhere else for Linux.. don't know much about linux, sorry.

Member Avatar for od3_85
0
220
Member Avatar for Clockowl

Hey guys, I know the title isn't possible, but I'd like to here how you'd do it then. Suppose we have this code: [code=cpp] Class Foo {public: int x; }; //somewhere in the code.. int main() Foo one, two; one.x = 10; two.x = 20; Foo *a = &one; Foo …

Member Avatar for Narue
0
178
Member Avatar for Clockowl

Hey guys, I have this code snippet: [code=cpp] template <typename ElementType, typename CompareClass> struct Delegate { virtual bool geef(const ElementType &element){ pair <set<ElementType, CompareClass>::iterator, bool> ret; //this is line 196 ret = elements.insert(element); //197 return (ret.second); //198 } virtual void output() = 0; set<ElementType, CompareClass> elements; }; struct ArtiestenPrinter : …

Member Avatar for Clockowl
0
222
Member Avatar for Clockowl
Member Avatar for drjay1627

[code=cpp] #include <cstdio> using namespace std; void testing(const void *buf){ puts((char*)buf); } int main() { char *x = "somebytes"; testing(x); return 0; }[/code] That works here, does that small program also work for you?

Member Avatar for dkalita
0
242
Member Avatar for Clockowl

Hey guys, I'm trying to create an MSCache (2 times MD4) cracker. I took the RFC thingy and implemented it in a cracker which is.. fast, but not as fast as I'd like it to be. So I searched a bit and stumbled on MDCrack, which claims it can do …

Member Avatar for dzhugashvili
0
463
Member Avatar for Zcool31

This might come in handy as well: [url]http://www.cplusplus.com/reference/std/typeinfo/type_info/[/url]

Member Avatar for Zcool31
0
232
Member Avatar for Clockowl

Hey guys, Can I tell istream to ignore ALL the characters until the delimiter char? It can be done with a loop but it's kinda weird I can't tell istream "discard until this char" imho, so maybe there's an hidden option somewhere. Thanks in advance!

Member Avatar for Narue
0
281
Member Avatar for llemes4011

What wildgoose gives as a solution is called a "forward declaration", so you can read up about it (where what why how etc.) And yes, Pancake stacks are most of the time FILO ones. xD ;)

Member Avatar for llemes4011
0
155
Member Avatar for anilopo

You can't call calc() in the product class. calc() isn't implemented in the Product class! ;) What you're doing in the ctor is basically: [code=cpp] Product :: Product (...) { this->price = this->calc (); } [/code] And since "this" in that context is a Product*, you can't call calc().

Member Avatar for ShawnCplus
0
262
Member Avatar for Clockowl

Hey guys, So I have compiled my first home-written static library (named PixGUI) that happens to call OpenGL functions. However, I noticed that when compiling (using MinGWs GCC with Code::Blocks project set to "static library") it doesn't matter whether I supply the linker with libopengl32.a or not, it simply compiles …

Member Avatar for Clockowl
0
207
Member Avatar for Clockowl

Hey guys, Below code isn't working as I expect it to do. I expect it to read all params when 6 are given, buuuuuuuuuuuut it only reads one, the rest remains zero. It does enter the case, but the stringstream buf seems empty. What am I doing wrong? [code=cpp] #include …

Member Avatar for Clockowl
0
167
Member Avatar for Clockowl

Hey guys, What am I doing wrong here? sss.hpp [code=cpp] #include <fstream> #include <string> #include <map> namespace sss { using namespace std; class node { public: multimap<string, string> values; multimap<string, node> children; string &value(const string name, size_t index = 0); node &child(const string name, size_t index = 0); private: template …

Member Avatar for Clockowl
0
689
Member Avatar for Clockowl

Hey guys, How would I partially specilize a template in a manner as below? Is that even possible? I have these two functions: [code=cpp] bool node::read(const char *filename) { ifstream f(filename); if (!f.good()) return false; bool success = read(f); f.close(); return success; } bool node::write(const char *filename) { ofstream f(filename); …

Member Avatar for Clockowl
0
511
Member Avatar for Clockowl

Hey guys, I have a class with a friend function and a member function with the same name. Calling the friend function from the member function gives me an error: it looks for <classname>::<function> while the friend function is of course simply <function>. In this case, MinGW GCC says: [code] …

Member Avatar for Clockowl
0
178
Member Avatar for Clockowl

Hey guys, With this defintion: sss.hpp [code=cpp] #include <fstream> #include <string> #include <map> namespace sss { using namespace std; class node { public: multimap<string, string> values; multimap<string, node> children; string &value(const string name, int index = 0); node &child(const string name, int index = 0); //... }; typedef pair<string, string> …

Member Avatar for ArkM
0
92
Member Avatar for ShadowScripter

Is it a Windows handle, the one in windows.h? It's not an initializer, it's what int and char are: a type. If it's a window handle, it's basically as specific as a pointer. A pointer used by windows to keep track of resources, varying from windows (window handles) to files …

Member Avatar for ShadowScripter
0
108
Member Avatar for jomacho

It doesn't compile in MinGW's GCC. Looks like MSVC code? I'm getting these errors: [code] =| sdvrp.h|18|warning: ignoring #pragma warning | sdvrp.h|222|warning: no newline at end of file| genius.cpp||In function `double genius(route*&, Nb&)':| genius.cpp|732|warning: comparison between signed and unsigned integer expressions| genius.cpp|733|warning: comparison between signed and unsigned integer expressions| genius.cpp|736|error: …

Member Avatar for tux4life
0
127
Member Avatar for Clockowl

Hey guys, I got this code, and I can't get it to compile, no clue what I'm doing wrong. [code=cpp]#include <iostream> #include <vector> #include <iterator> using namespace std; template <class T> void kill_dupes(vector<T> &x){ vector<T> y; for(vector<T>::iterator it = x.begin(); it != x.end(); it++){ if(find(x.begin(), x.end(), *it) == x.end()){ y.push_back(*it); …

Member Avatar for siddhant3s
0
2K
Member Avatar for Stefano Mtangoo
Member Avatar for NicAx64
0
440
Member Avatar for Clockowl

Hi guys, What am I doing wrong here? Program dies on me @ merge(). :( [code=cpp]#include <iostream> #include <vector> using namespace std; int main() { int afrom[4] = {0,0,1,2}; int ato[4] = {1,2,3,4}; vector<int> from(&afrom[0], &afrom[4]); vector<int> to(&ato[0], &ato[4]); vector<int> length; vector<int> all_nodes; sort(from.begin(), from.end()); sort(to.begin(), to.end()); merge(from.begin(), from.end(), to.begin(), …

Member Avatar for Clockowl
0
123
Member Avatar for ihatehumans

Your overloaded >> is a bit complicated, here's a simpler version: [code=cpp]int main() { int nom, denom; string buf; getline(cin, buf); stringstream ss(buf); ss >> nom; //discard all the remaining chars, stop when / is found ss.ignore(ss.str().length(), '/'); ss >> denom; cout << "Read: " << nom << "/" << …

Member Avatar for siddhant3s
0
205
Member Avatar for ShadowScripter

Does this code compile for you? [code=cpp]int main(){ size_t cols = 10; cin >> cols; size_t rows = 20; cin >> rows; char x[cols][rows]; for(int i = 0; i < rows; i++){ for(int n = 0; n < cols; n++){ cout << x[i][n]; } cout << endl; } return 0; …

Member Avatar for ShadowScripter
0
710
Member Avatar for Usura

Tux4life is right, you can't delete one element of an array in C(++). Either use a vector or do as tux4life said.

Member Avatar for tux4life
0
81
Member Avatar for SmokyMo

This'd work. [code=cpp] string filepath; getline(cin, filepath); ifstream fis(filepath.c_str()); [/code]

Member Avatar for tux4life
0
90
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
181
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
185
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
213
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
150
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
111
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
196
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
769
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
217
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
229
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
194
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
732
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
244
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
108
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
138
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
123
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
111
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
151
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
91

The End.