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 is attached. For the record: I want to merge the unallocated "partition" on Data with Data so it regains it's ~40GB. Thanks in advance!

Member Avatar
Member Avatar
+0 forum 9

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 *b = &two; //We want to compare Foo::x here, not the pointers. bool result = a > b; return 0; } [/code] How would you implement this? I've thought about a compare class, as the STL containers do, and ofcourse a compare functions, but I'd like to hear if there …

Member Avatar
Member Avatar
+0 forum 4

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 : public Delegate<Lied, LiedCompare> { virtual bool geef(const Lied &lied){ bool nieuwElement = Delegate<Lied, LiedCompare>::geef(lied); // 210 if (nieuwElement) { cout << lied.artiest; } return nieuwElement; } virtual void output(){ for(set<Lied, LiedCompare>::iterator it = elements.begin(); it != elements.end(); it++){ cout << it->artiest << endl; } } }; [/code] Which gives me …

Member Avatar
Member Avatar
+0 forum 1

Nevermind.

Member Avatar
+0 forum 0

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 about 10 million MD4 hashes per second on my system, while I only get 4 million per second. Since it's open source, I downloaded the source code of an old version and studied the MD4 algorithm, and it seems to partially reverse it. However, I lack knowledge of just about …

Member Avatar
Member Avatar
+0 forum 1

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
Member Avatar
+0 forum 4

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 each time. However, when I link PixGUI to another project, i.e. Pixlings, and try to compile that, it gives me these errors: [code]||=== Pixlings, Release ===| ..\PixGUI\lib\libPixGUI.a(button.o):button.cpp:(.text+0xc1)||undefined reference to `glColor3fv@4'| ..\PixGUI\lib\libPixGUI.a(button.o):button.cpp:(.text+0xea)||undefined reference to `glRectf@16'| ||=== Build finished: 2 errors, 0 warnings ===| [/code] The build log of libPixGUI.a (without supplying …

Member Avatar
Member Avatar
+0 forum 2

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 <iostream> #include <fstream> #include <sstream> using namespace std; #define SCREAM cout << "OMAGAWD" << endl int main(int argc, char *argv[]) { // <src> <dest> [<offset> [<bytes, 0 = all> [<offset>]] //writes bytes bytes from src+offset to dest+offset size_t in_offset; size_t bytes; size_t out_offset; in_offset = bytes = out_offset = 0; …

Member Avatar
Member Avatar
+0 forum 2

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 <typename T1, typename T2> T2 &searchInsert(multimap<T1, T2> &container, const T1 &name, size_t index = 0) { typename multimap<T1, T2>::iterator it = container.find(name); //found none, insert... if (it == container.end()) { it = container.insert(pair<T1, T2>(name, T2())); return it->second; } //found one, multimap is sorted, iterate to index-th element or the end. …

Member Avatar
Member Avatar
+0 forum 3

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); if (!f.good()) { return false; } bool success = write(f); f.close(); return success; } [/code] And I'd like to create a function like this: [code=cpp] template <typename T> bool node::read_or_write(const char *filename) { T f(filename); if (!f.good()) { return false; } bool success; if(T == ifstream){ success = write(f); } …

Member Avatar
Member Avatar
+0 forum 10

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] \Code\RationalNumber\rational.cpp | In member function `long long unsigned int rational::gcd() const': \Code\RationalNumber\rational.cpp | error: no matching function for call to `rational::gcd(const long long unsigned int&, const long long unsigned int&) const' \Code\RationalNumber\rational.cpp | note: candidates are: long long unsigned int rational::gcd() const [/code] How do I circumvent this naming collision …

Member Avatar
Member Avatar
+0 forum 3

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> value; typedef pair<string, node> child; typedef multimap<string, string>::iterator valueiterator; typedef multimap<string, node>::iterator childiterator; }[/code] and this implementation: sss.cpp [code=cpp]#include <iostream> #include <fstream> #include <map> #include <string> #include "sss.hpp" using namespace std; using sss::node; using sss::valueiterator; using sss::childiterator; string& node::value(const string name,int index) { valueiterator it = values.find(name); try { int …

Member Avatar
Member Avatar
+0 forum 4

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); } } x = y; return; } int main(){ return 0; }[/code] GCC MinGW says: [code]main.cpp||In function `void kill_dupes(std::vector<T, std::allocator<_CharT> >&)':| main.cpp|12|error: expected `;' before "it"| main.cpp|12|error: `it' was not declared in this scope| main.cpp||In function `void kill_dupes(std::vector<T, std::allocator<_CharT> >&) [with T = int]':| main.cpp|31|instantiated from here| main.cpp|12|error: dependent-name ` …

Member Avatar
Member Avatar
+0 forum 13

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(), to.end(), all_nodes.begin()); return 0; }[/code] Thanks in advance,

Member Avatar
Member Avatar
+0 forum 3

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 allow the non-free blocks to be clicked/removed, so the program can click away. Check which ones are the same and remove those. //Will send input, but this part is covered. } [/code] So obviously there are tons of algorithms for image recognition, but I was wondering if anyone knew the …

Member Avatar
Member Avatar
+0 forum 3

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, get pointer, rewind file.seekg(0, ios_base::end); size_t file_size = file.tellg(); file.seekg(0, ios_base::beg); if (!file.good()) { throw runtime_error("Fatal error while getting filesize."); } //read file in string from ifstream //allocate array, read file in array, set the term. null byte, set string to array char *file_content; try { file_content = new char …

Member Avatar
Member Avatar
+0 forum 7

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> #include <new> /* load_file(filepath, destination) -Returns whether it succeed or not. True meaning succeeded. -Takes a path and writes to a std::string, completely memory safe. */ bool load_file(const char *filepath, std::string &dest) throw (std::bad_alloc) { using namespace std; ifstream file; file.open(filepath, ios::binary); if (!file.good()) { cerr << "Fatal error while …

Member Avatar
Member Avatar
+0 forum 1

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, rewind file.seekg(0, ios_base::end); size_t file_size = file.tellg(); file.seekg(0, ios_base::beg); if(!file.good()){ cerr << "Fatal error while getting filesize." << endl; return false; } //read file in string from ifstream //allocate array, read file in array, set string to array char *file_content = new char [file_size+1]; file.read(file_content, file_size); cout << file_content; dest …

Member Avatar
Member Avatar
+0 forum 7

Hey guys, I was wondering, with this code: main.cpp [code=cpp] #include <iostream> using namespace std; class car { public: car (float speed) : speed(speed) {} car () : speed(0) {} void cruise(float speed) { this->speed = speed; cout << "New speed: " << getSpeed() << endl; } void brake(float power) { this->speed -= power*power/4; } float getSpeed() { return speed; } private: float speed; }; class racer : public car { public: void boost(float power) { cout << "BOOST! "; cruise(getSpeed() + power*power/3); } }; class tank : public car { public: bool shoot(float aimTime) { cout << "Shot "; …

Member Avatar
Member Avatar
+1 forum 7

'lo there folks, MinGW's giving me 1 error I can't get rid of: [code] eventhandler.h|9|error: `element' has not been declared| eventhandler.h|9|error: ISO C++ forbids declaration of `elem' with no type| [/code] All code mentioned and I think needed: eventhandler.h [code=cpp] #ifndef EVENTHANDLERH #define EVENTHANDLERH #include "element.h" enum events {onClick, onHover}; typedef struct eventHandlerT { void(*func)(element *elem); events eventType; } eventHandler; #endif // EVENTHANDLERH [/code] element.h [code=cpp] #ifndef ELEMETH #define ELEMETH #include "eventhandler.h" class element { public: element(); ~element(); void processEvent(events event); vector<eventHandler> handlers; unsigned int ID; static unsigned int IDcount; }; #endif // ELEMETH [/code] Why is element not declared? …

Member Avatar
Member Avatar
+0 forum 4

Hey guys, I was wondering if the stringstream class copied the string to itself or just keeps a pointer. Because if it copies I can free or clear the string without fearing for the data in stringstream. EDIT: Like this: [code=cpp] string stringz0r("Chickenz"); stringstream streamz0r(stringz0r); //will this not affect the stringstream in any way? stringz0r.clear(); [/code] Or, maybe a bit more complicated: [code=cpp] string *stringz0r = new string("Chickenz"); stringstream *streamz0r = new stringstream(*stringz0r); //will this... delete stringz0r; [/code] Thanks in advance, Nick

Member Avatar
Member Avatar
+0 forum 2

Hey guys, I was wondering... I always assumed that references were more or less constant "dereferenced" pointers. With that in my mind I tried to do this: [code=cpp] #include <iostream> #include <string> using namespace std; void outputIt(const string * const textz00rs){ cout << *textz00rs << endl; } int main(){ outputIt("window"); return 0; } [/code] But that'll give me the error: [icode]cannot convert `const char*' to `const std::string*' for argument `1' to `void outputIt(const std::string*)'[/icode] So I tried: [code=cpp] #include <iostream> #include <string> using namespace std; void outputIt(const string &textz00rs){ cout << textz00rs << endl; } int main(){ outputIt("window"); return 0; …

Member Avatar
Member Avatar
+0 forum 3

Hey guys, I'm getting this kinda vague error: Zeal\src\window.cpp|19|error: cannot declare member function `static unsigned int zeal::window::getWindowCount()' to have static linkage| With the following code (only what I think is needed, if you need more please do ask) window.h [code=cpp]namespace zeal { class window : public element { public: static unsigned int getWindowCount(); private: static unsigned int windowCount; }; }[/code] window.cpp [code=cpp]unsigned int zeal::window::windowCount = 0; namespace zeal { static unsigned int window::getWindowCount(){ return windowCount; } }[/code] It's only called once from main, I want to call it like this: main.cpp (one line only) [code=cpp] cout << "Nr of windows: …

Member Avatar
Member Avatar
+0 forum 2

Hey guys, Could I "teach" my compiler to do automatic type conversions for me? So when I have this program: [code=cpp] #include <cstdio> #include <string> using std::string; int main(){ int x; string y = "1234567890"; x = y; printf("y: %s == %d\n", y.c_str(), x); return 0; } [/code] It won't give me [icode]main.cpp|10|error: cannot convert `std::string' to `int' in assignment|[/icode] But compile and do everything alright? I know C++ has this function somewhere since it can do a lot of conversions without having to use functions on the line itself (i.e. by simply casting), but I couldn't find details about …

Member Avatar
Member Avatar
+0 forum 11

Hey guys, I'm stuck on some undefined references to glut and OpenGL, even when I linked my projects with the correct libraries. Well apparently they aren't correct... I'm trying to compile this: [code=C] /* Copyright (c) Mark J. Kilgard, 1994. */ /* This program is freely distributable without licensing fees and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. */ #include <GL/glut.h> GLfloat light_diffuse[] = {1.0, 0.0, 0.0, 1.0}; GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0}; GLUquadricObj *qobj; void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glCallList(1); /* render sphere display list */ …

Member Avatar
Member Avatar
+0 forum 1

Hey guys, This program gives me a nice segfault (on line 27 and if it's removed on the realloc() below that) and I can't seem to figure out why. Any help is greatly appreciated. [code=c] #include <stdio.h> #include <stdlib.h> #include <string.h> /* Parses parse_this for tokens using strtok() with seperators (but doesn't alter parse_this due to internal copy) and puts tokens into array_of_strings. array_of_string (out): should be a NULL pointer in the beginning. nr_of_strings (out) : contains the number of strings parse_this (in) : string to be parsed seperators (in) : seperators to be passed to strtok() */ int cexplode(char …

Member Avatar
Member Avatar
+0 forum 7

EDIT for moderators: Yes that "one might think that swapbuffer is slow" was me. Heh. :D Could someone change the topicname to "Optimizing OpenGL"? Thanks. Hey guys, I'm trying to optimize this OpenGL program, so the problem isn't C, but the program is. The program loads a vanilla WaveFront .obj file, stores all it's data in an array, creates a display list, uses glDrawElements to put it in the display list and then calls the display list as often as it can. For my test file, this "how often as it can" gives an FPS of about 37. While this …

Member Avatar
Member Avatar
+0 forum 10

Hey guys, I was wondering if realloc() copied the contents of the block of memory to the new block "on most compilers" IF the new size is bigger. I like to learn good ways to program something, but don't want to reinvent realloc just because it doesn't work on <reallyoldcompiler>. Thanks in advance,

Member Avatar
Member Avatar
+0 forum 7

Is it possible to read a whole file at once with text files, or can I only use fgets and is that the most data I can fetch at any time? (fread() doesn't work on text files, I've experienced and then been told ;-)). Thanks in advance, PS: And suppose I use fseek, ftell, to get the filesize of a file, is that size+1 the correct size for the buffer to read in the complete file using series of fgets calls?

Member Avatar
Member Avatar
+0 forum 9

How would I reuse functions in C? I've tried simply sticking them in a [icode]#include <myfunctions.h>[/icode], but that didn't work... Any (complete) suggestions/links on how to do this? I googled some and found this: [code]The way to write a header file is: functions.h: int sum( int a, int b) ; functions.cpp: #include "functions.h" int sum( int a, int b) { return a+b ; } compile: g++ -c functions.cpp -o functions.o main.cpp: #include "functions.h" main() { cout << sum(1,2) << endl ; } compile and execute main: g++ main.cpp functions.o -o main main[/code] How would I, obviously replacing g++ with gcc …

Member Avatar
Member Avatar
+0 forum 2

The End.