50 Discussion / Question Topics

Remove Filter
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
154
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 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 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 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 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 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 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 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
107
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 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
997
Member Avatar for Clockowl

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) …

Member Avatar for stephen.id
1
246
Member Avatar for Clockowl

'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}; …

Member Avatar for Clockowl
0
101
Member Avatar for Clockowl

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 …

Member Avatar for Clockowl
0
123
Member Avatar for Clockowl

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"); …

Member Avatar for Narue
0
313
Member Avatar for Clockowl

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 …

Member Avatar for Clockowl
0
87
Member Avatar for Clockowl

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 …

Member Avatar for Clockowl
0
112
Member Avatar for Clockowl

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 …

Member Avatar for Lerner
0
459
Member Avatar for Clockowl

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 …

Member Avatar for Salem
0
113
Member Avatar for Clockowl

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 …

Member Avatar for veelck
0
1K
Member Avatar for Clockowl

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>. …

Member Avatar for Salem
0
306
Member Avatar for Clockowl

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 …

Member Avatar for WaltP
0
450
Member Avatar for Clockowl

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) ; …

Member Avatar for Clockowl
0
107
Member Avatar for Clockowl

Does anyone know if it's possible to create a shellscript that knows when it's fopen()ed? So when any process fopens() it, it can take an action? Thanks in advance,

0
111
Member Avatar for Clockowl

Howdy folks, Does anyone know if GCC is capable of creating a fixed length 1D array of an N-Dimensional array for reasons of speed? I've heard it matters quite a lot if one works constantly with N-Dimensional (with N != 1) compared to 1D arrays in terms of speed, but …

Member Avatar for grumpier
0
90
Member Avatar for Clockowl

Is it possible to put compile-time conditional code in template functions? Kinda like, [code=cpp] template <class T> void print(T &foo){ cout << foo; #if T == float cout << " is a float." << endl; #endif }[/code] Something like that, I hope I made myself clear. Thanks in Advance,

Member Avatar for Clockowl
0
95
Member Avatar for Clockowl

Hey guys, How would one create a vector of pointers to functions? I know from C to create an array of functions, but I'd like to learn how to do it with vectors as well. Here are my efforts so far: [code=cpp]#include <iostream> #include <valarray> #include <vector> #include <ctime> #include …

Member Avatar for Clockowl
0
148
Member Avatar for Clockowl

Hi guys, I've got two loops, and I want to be able to continue; the outermost loop when the innermost loop finds something. How would I do that? [code=c] //(...) for (n = startStorage; n < quadcount; n++) { if (!notOptimized(n, optimized)) continue; int *x = &quadindex[n*4]; for (eachX = …

Member Avatar for Clockowl
0
123
Member Avatar for Clockowl

Hey guys, I've written quite a large piece of code the past few days, and today I've cleaned it up a bit, divided it into functions (I know, bad, should've done it the other way around) etc. etc. The project is a simple 3D thingamadingy, the program is able to …

Member Avatar for Clockowl
0
210
Member Avatar for Clockowl

Hi guys, Could you tell me what's wrong with this code? I don't get why the compiler says it can't find a matching function... [code=cpp]#include <iostream> #include <vector> using namespace std; template <class T> int printVector(vector<T> &x){ for(unsigned int col = 0; col < x.size(); col++){ cout << x[col] << …

Member Avatar for Clockowl
0
109
Member Avatar for Clockowl

Hi guys, I'm getting a segfault and I don't really understand why.. Here is the code n, i, quadcount, quadPerVert and quadindex are all (arrays of) unsigned integers. [code=cpp]unsigned int *quadsPerVert = new unsigned int[quadcount * 4]; //(...) vector<vector<unsigned int> > quadsPerVertIndex; quadsPerVertIndex.reserve(quadcount * 4); for (n = 0; n …

Member Avatar for Clockowl
0
119
Member Avatar for Clockowl

Hi guys, I tried rewriting my C-ish C++ function to true C++, but I'm failing so far: The first function (working) [code=cpp]const visualPart * entity::getVisualPart(unsigned int wantLOD){ for(unsigned int i = 0; i < visualEntity.size(); i++){ if(visualEntity[i]->LOD == wantLOD){ return visualEntity[i]; } } return NULL; }[/code] And the second (not …

Member Avatar for Clockowl
0
99
Member Avatar for Clockowl

Hey guys, I'm parsing this WaveFront .obj file, still (for those that have read the previous post), but it has some really weird error in it that I haven't seen in a program before. The parsing algorithm starts out like this: [code]Open the file in textmode. Get filesize Allocate buffer …

Member Avatar for Prabakar
0
383
Member Avatar for Clockowl

Hey guys, An char* to string conversion looks to be generating a segfault. I'm pretty sure that's not it, but that's when GDB says it received one... Well, here's the, what I think, relevant code. If you think more code is relevant I'll post that too of course. Entity.h (objLocation …

Member Avatar for Clockowl
0
105
Member Avatar for Clockowl

Is there any difference between those function declarations in C++? Since in C the first states "take any and as much arguments as you like", and the latter means take none... Thanks in Advance, Nick

Member Avatar for Ancient Dragon
0
69
Member Avatar for Clockowl

Hi guys, I'm having this weird error with undefined references to static variables, and was wondering what I'm doing wrong. Here's the header: World.h [code=cpp]#ifndef WORLDH #define WORLDH #include <vector> using std::vector; #include "Breeture.h" class World{ friend class Breeture; public: World(vector<Breeture*> *initialBreetures); World(unsigned int mutChance, unsigned int breetures); void NewBreeture(const …

Member Avatar for Ancient Dragon
0
118
Member Avatar for Clockowl

Hey guys, I come over from C, wanting to learn C++. I have a nice little book but figured I could use a project to get me going. So I magicly crafted code, and ran into this problem: [icode]C:\Code\Rapture\World.h|7|error: ISO C++ forbids declaration of `Breeture' with no type|[/icode] With this …

Member Avatar for Clockowl
0
173
Member Avatar for Clockowl
Member Avatar for Clockowl

Hiya fellas, I just made this Knight's Tour program, and wish to speed it up without making it non-brute force. So it shouldn't have any intelligence. I did most I could, and was wondering if you guys know more ways to speed this program up. First thing I thought about …

Member Avatar for Jishnu
0
164
Member Avatar for Clockowl

Hey, When quick googling didn't really clarify, I'd like to ask here. When declaring an N-dimensional array, 2D in this case, how to set them all to zero? For 1D arrays it should work with type name[n] = {0}; Is the same approach also guaranteed to work for N-Dimensional arrays …

Member Avatar for Salem
0
272
Member Avatar for Clockowl

hai. I'm trying to compile a program split up across multiple files. The code is far from complete, but I noticed lots of compiler warnings and errors. This ought to be due to splitting the code up: I thought the preprocessor simply copy and pasted the code into main.c when …

Member Avatar for Clockowl
0
127
Member Avatar for Clockowl

Hai guys, I have quite a large program here that I don't seem to understand. The program, Bow Vice Jet (an anagram for object view) is meant to display WaveFront .obj files. However, it quits when it loads a specific file while on my computer, while on another it does …

Member Avatar for jephthah
0
148
Member Avatar for Clockowl

Hai all, I ran into a strange issue I never experienced before. Pointers are passed to function, the function allocates memory to them with calloc, and right before the return sanity checks if the pointers still != NULL. That check succeeds, but upon returning and sanity checking in the calling …

Member Avatar for Clockowl
0
102

The End.