156 Posted Topics
Re: [URL="http://nsis.sourceforge.net/Main_Page"]Nullsoft installer[/URL]. Kicks ass! | |
Re: If your coding C, why post in the C++ forum? Anyway, show some code. A quick google gives me this: [url]http://weseetips.com/2008/08/27/how-to-set-color-for-static-control-text-in-dialog/[/url] and [url]http://www.programmersheaven.com/mb/mfc_coding/147975/147975/how-do-you-change-static-text-box-text-color/?S=B20000[/url] Don't know if they are addressing your problem. | |
Re: What doesn't work? new doesn't set the allocated memory to 0, could that be a problem? Be a bit more specific please. | |
Re: char *file? If you're using fgets(), I'm guessing it wants a C-style FILE *. ;) Anyway, you're in C++ land now, try getline() or something like that. Safer, easier. Other then that, the code is kinda.. bad.. You've a loop that fetches data from the ifstream into your char array, … | |
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> … | |
Re: Create an array/vector of the struct (or pointers to), iterate it, compare the member variables to what you are looking for. | |
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, … | |
Re: Well lionleo, welcome to Daniweb: where we don't code homework assignments for others. :D What's the problem? Do you know how to read in a file? Grab lines from that file? Parse those lines? | |
Re: [code=cpp]void Employee::set(double payRate, int hours) { cin >> payRate; cin >> hours; }[/code] Change that to... [code=cpp]void Employee::set(double payRate, int hours) { this->payRate = payRate; this->hours = hours; }[/code] I'm not guarranteeing that it works on every compiler, but I think it should. If you don't understand the code, let … | |
Re: This is not C, I have no clue what language this is, sorry. | |
Re: [icode]singleIMEI singleIMEIarr[30] = {'\0'};[/icode] That's a NULL char. ;) By definition arrays in C NOT dynamically allocated are always completely 0. | |
Re: You're better of posting this in the C forum, but meh. The function takes 6 char pointers, pointing to a block of chars terminated by '\0' I presume. You need to separate 1 string into 5 others, guess what the other 5 are for? [code=c] char here[7]; char a[2]; char … | |
Re: And, not related to programming, you're squaring it, not square rooting it. | |
Re: I know you like ambitious projects: [quote=Laik]I am going to make OS. And I need help with GUI...how to make an GUI ?...I am not on Windows so CreateWindowEx() doesn't exist.[/quote] But I suggest starting of with the easy stuff, hehe. :D | |
Re: Scan the set until you find a value higher or lower (depends on how you sort) then the current value, insert it there? | |
Re: File Dump? Clarify yourself a bit, maybe with a small program? | |
Re: errr.. what? Is this a question or.. an answer to no question? I don't get it. | |
Re: Could you try this simple program and tell me if it has any errors? [code=cpp] #include <iostream> #include <vector> using namespace std; struct cluster { string name; }; int main() { vector <cluster> clusters (3); clusters[0].name = "test"; cout << clusters[0].name << endl; string overwrite("OH YEAH!"); clusters[0].name = overwrite; cout … | |
Re: [code=cpp]void shoot(int ammo, double hitPercent, int hit, int miss, int shotsFired)[/code] should be [code=cpp] void gun::shoot(int ammo, double hitPercent, int hit, int miss, int shotsFired)[/code] Do you know what a static data member means in C++? It seems unlikely that every gun shares the same number of bullets. ;) | |
| |
Re: [code]read sentences add weights[/code] ? ;) Post a bit more information if you don't know how to do one of the two steps above and maybe even a bit of code? | |
Re: [code=cpp] while(firstTry == true) { { cout << "It Is Your First Try, We Will Create My Array First:\n"; updateArr(arr, size); } return firstTry = false; //Don't return here, hehe. } [/code] Should be something along the lines of.. [code=cpp] if(firstTry == true) { cout << "It Is Your First … | |
Re: Sorry if this sounds harsh, but there are numerous problems with your code's logic. Is it guarranteed that there are a max of 7 tokens in your strings? And that the size of those is 99 chars max? And that all of the lines in your file don't contain whitespace? … | |
Re: You're outputting a regular text file if I'm not mistaken. The Word Document format is closed and (therefore) hard to understand. Tagging ".doc" on the end of your filename doesn't make it a Word Document. | |
Re: You can easily test that, just put some messages in the destructor and some in the program itself to see its place right? ;) | |
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) … ![]() | |
Re: Maybe make sure that conversion is going alright? Output (char) (event.key.keysym.unicode) or something. ASCII chars in UTF-8 might be something like, {\x00\x<ASCII-code>}, in that case, you're appending \x00 ;). It's my best guess. | |
Re: Hey, in the past I've messed with those functions a bit, here're the results. Might help you a bit. Finds a window given a caption: [code=c]#include <windows.h> #include <stdio.h> int main(int argc, char *argv[]){ HWND hWnd; char windowName[512]; printf("Window to look for: "); fgets(windowName, 512, stdin); if (hWnd = FindWindow(NULL, … | |
Re: You used defines in C++, most people look down on that for the reason that you can also use (static) const unsigned ints in your case. It has the benefit of type checking. The array initialization is okay with the brackets, but if you make it a loop you won't … | |
'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 … | |
Re: You need to include a .lib, .dll or .a file from the library you are using I guess. What are you exactly doing/trying to do? | |
| |
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 … | |
Re: I'm more of a newb but feeling cocky as always: Don't AVOID compiler specific functions, but be sure to find a cross-compiler way to do it as well, as in: find it, use it a couple of time, memorize it. However, I think it's a definite plus if you also … | |
Re: Well for one change your extension from .cpp to .c, since there's no other way for the compiler to know if it's compiling C or C++ code (except maybe a parameter). | |
Re: # students = malloc(sizeof(struct student)); # strcpy(students[0]->name, "jack"); I might have missed it, but of what type is "students"? It seems to be an int, since the declaration is lacking a type. | |
Re: Narrow the problem down a bit and you'll recieve more help. | |
Re: Only plain wrong if you're not using a compiler that has defined it. Given that that's not the case most of the time: check your compiler's documentation and see if you can use it, then, bare in mind that this code is not 100% portable and SHOULD input not work … | |
Re: You wouldn't want to do that, I think it's undefined behaviour when you try to do that. Why can't you create your array of char arrays like Aia said? [code=c]char d[][5][/code] | |
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>. … | |
Re: Regression? Don't you mean iteration? Could be wrong, but according to wiki (I had to look it up) regression is bug-related, not loop related like recursion. If you mean iteration, then that is faster. But, recursion could give you a lot cleaner code, so it's basically okay to write big … | |
Re: Define "doing the same thing". I can drive to the store on my bike and in my car, doing 2 different things. Or I can say that I'm going to the store, doing one thing, in 2 ways. C compilers will probably never output exactly the same output as when … |
The End.