156 Posted Topics

Member Avatar for Niner710
Member Avatar for ArkM
0
125
Member Avatar for JohnKeays

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.

Member Avatar for nucleon
0
89
Member Avatar for pt_solar

What doesn't work? new doesn't set the allocated memory to 0, could that be a problem? Be a bit more specific please.

Member Avatar for Clockowl
0
2K
Member Avatar for Gerlan

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

Member Avatar for Gerlan
0
126
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 rudolph2004

Create an array/vector of the struct (or pointers to), iterate it, compare the member variables to what you are looking for.

Member Avatar for rahul8590
0
84
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 lionleo

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?

Member Avatar for ithelp
0
79
Member Avatar for ejiroy

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

Member Avatar for VernonDozier
1
93
Member Avatar for pridathabah
Member Avatar for vishy_85

[icode]singleIMEI singleIMEIarr[30] = {'\0'};[/icode] That's a NULL char. ;) By definition arrays in C NOT dynamically allocated are always completely 0.

Member Avatar for Ancient Dragon
0
1K
Member Avatar for lancevo3

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 …

Member Avatar for nucleon
0
112
Member Avatar for jam7cacci

And, not related to programming, you're squaring it, not square rooting it.

Member Avatar for jam7cacci
0
107
Member Avatar for Laik

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

Member Avatar for siddhant3s
0
259
Member Avatar for boydale1

Scan the set until you find a value higher or lower (depends on how you sort) then the current value, insert it there?

Member Avatar for Clockowl
0
109
Member Avatar for 3pid
Member Avatar for MosaicFuneral
0
75
Member Avatar for Alicito

errr.. what? Is this a question or.. an answer to no question? I don't get it.

Member Avatar for Ancient Dragon
0
893
Member Avatar for everard
Member Avatar for cy163

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 …

Member Avatar for Clockowl
0
97
Member Avatar for connoisseurodg

[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. ;)

Member Avatar for Clockowl
0
144
Member Avatar for kelechi96
Member Avatar for Ancient Dragon
0
141
Member Avatar for sautap4u

[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?

Member Avatar for nucleon
0
112
Member Avatar for JainishP

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

Member Avatar for Clockowl
0
156
Member Avatar for Usura

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

Member Avatar for Clockowl
0
115
Member Avatar for hurbano

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.

Member Avatar for Clockowl
0
73
Member Avatar for sciwizeh

You can easily test that, just put some messages in the destructor and some in the program itself to see its place right? ;)

Member Avatar for ArkM
0
3K
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 sciwizeh

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.

Member Avatar for sciwizeh
0
145
Member Avatar for FTProtocol

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

Member Avatar for fskreuz
0
1K
Member Avatar for cproud21

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 …

Member Avatar for Clockowl
0
94
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 andreb

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?

Member Avatar for Clockowl
0
117
Member Avatar for zedame
Member Avatar for Freaky_Chris
0
116
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 Whilliam

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 …

Member Avatar for Whilliam
0
248
Member Avatar for xlx16

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

Member Avatar for ArkM
0
96
Member Avatar for BigFormat

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

Member Avatar for Clockowl
0
3K
Member Avatar for JustLearning
Member Avatar for En-Motion

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 …

Member Avatar for WaltP
0
148
Member Avatar for anny**
Member Avatar for dusse

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]

Member Avatar for Aia
0
345
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 cutedipti

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 …

Member Avatar for Narue
0
98
Member Avatar for serkan sendur

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 …

Member Avatar for Ancient Dragon
0
333

The End.