- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 8
- Posts with Upvotes
- 8
- Upvoting Members
- 7
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
Almost Uni Student.
Re: 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. … | |
Re: 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 | |
| |
Re: [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! ;) | |
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 … | |
Re: 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. | |
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 : … | |
Re: [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? | |
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 … | |
Re: This might come in handy as well: [url]http://www.cplusplus.com/reference/std/typeinfo/type_info/[/url] | |
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! | |
Re: 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 ;) | |
Re: 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(). | |
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> … | |
Re: 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 … | |
Re: 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: … | |
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); … | |
Re: I really enjoy GTK+/gtkmm. :) Lots of demos and documentation. | |
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(), … | |
Re: 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 << "/" << … | |
Re: 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; … | |
Re: Tux4life is right, you can't delete one element of an array in C(++). Either use a vector or do as tux4life said. | |
Re: This'd work. [code=cpp] string filepath; getline(cin, filepath); ifstream fis(filepath.c_str()); [/code] |