50 Discussion / Question Topics
Remove Filter 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 … | |
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 … | |
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 : … | |
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 … | |
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! | |
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 … | |
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 … | |
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 … | |
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); … | |
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] … | |
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> … | |
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); … | |
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(), … | |
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 … | |
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, … | |
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> … | |
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, … | |
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) … ![]() | |
'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}; … | |
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 … | |
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"); … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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>. … | |
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 … | |
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) ; … |
The End.