User Profile
Collapse
-
Thanks a lot. I was focusing on the WNDPROC parameter. You are right. -
What is warning "C4090"?
I have the following function declared:
My window procedure is defined as follows:Code:void RegisterMyClass(HINSTANCE hinst, WNDPROC wproc, char* clsName)
I call "RegisterMyClas s" declared above as follows:Code:LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
...Code:RegisterMyClass(hInstance,
-
Unions can be thought of "variants" in other programming languages.Leave a comment:
-
If you're really concerned, you can just write a function like this:
Or perhaps this:Code:int CharToInt(char c) { char digits[] = "0123456789"; int i; for (i=0; i<=9; i++) if (c == digits[i]) return i; return -1; }
...Code:int CharToInt2(char c) { char *digits = "0123456789"; char *posLeave a comment:
-
Thanks so much! This is a great article. I will rewrite my app accordingly....Leave a comment:
-
-
-
I discovered the problem was with SleepEx(). I ran a diagnostics program that I wrote. It takes 157 ms to execute a loop containing 100 ms worth of SleepEx() calls on my work computer. On my home computer, it's exactly 100 ms.Leave a comment:
-
By the way, I just tried your code in Visual C++ 2008, and it actually works just fine as is. The value of N4 is 4 (not 4000). The only thing I changed is I added (char *) before ReceivedStr:
char *ReceivedStr = "P0004";
But what I said earlier is still true if I'm understanding the C spec correctly. According to the specification of the C language, atoi requires a null-terminated string.Leave a comment:
-
Instead of:
PosToMoveTo = atoi(&N4);
You can try:
PosToMoveTo = (int) N4 - 48;
I believe that atoi() expects a null-terminated string. A char is not necessarily followed by a null terminator in memory, so when you give atoi a pointer to a char, it just keeps reading the contents of memory until it hits the null-terminator. It doesn't know that the length of your "string" is just one chara...Leave a comment:
-
Animation using pure C/Win32
As part of familiarizing myself with the Win32 API, I wrote a simple animation program in C. The program has a struct for each bitmap, holding information such as its location, visibility, mask (for transparency), etc. Then I have a separate thread running that has a WHILE loop that looks like this:
...Code:WHILE (TRUE) { /* update all structs (bitmap locations, etc) */ SleepEx(iSpeed, FALSE); InvalidateRect(hwnd, -
Thanks. I feel stupid. I did a search and found the answer on Google on how to make a GIF background transparent with "The Gimp". Now my photo browser looks semi-professional....Leave a comment:
-
How do I make control "buttons" look transparent in Javascript?
I wrote a gallery div where you see a photo, and at the top right corner of the photo I have images of arrows to go back and forth to see other photos, along with other controls.
My question is: My "controls" images (which I drew by hand) have a black background. Is there a way to make the background transparent so that all I see on the photo is the control itself? If this is not doable in Javascript, is it doable in Photoshop,... -
Well duh. I do apologize. I actually spent a half hour struggling with it, never noticing the stupid mistake....Leave a comment:
-
OK, I copied/pasted the code into my VC++ and it doesn't work. I get a 6 digit number instead of the expected string:
...Code:void SInit(char **s) { *s = malloc(sizeof(char)*25); } int main() { char *str; SInit(&str); strcpy(str, "Hello, World"); printf("%d", str); free(str); getch(); returnLeave a comment:
-
... and to change the value of the address itself, I need the address of the address....Leave a comment:
-
Thanks a lot. I think I understand now. In most cases, we change the content of the memory block by passing a pointer to it into the function. But what I was trying to do here is change the actual pointer by making it point at a different block of memory, and to do that I have to pass a pointer to that pointer.
Thanks for the explanation.Leave a comment:
-
I guess there is a gap in my understanding that I wasn't aware of. I don't see why I need to pass a pointer to a pointer.
For instance, given what you guys said, I don't understand why this code works. I'm changing the value inside the function and I don't need a pointer to a pointer to do it. There seems to be something about the "malloc" function that requires a pointer to a pointer, rather than just a pointer. "strcpy",...Leave a comment:
-
I'm passing an address in the first post too. I understand that C parameters by value.
Let me put it this way: Can you fix the code in the first post so that it works as intended? Maybe then I will understand what you're trying to tell me.Leave a comment:
-
But I'm passing an address. You can do that in C. For example, this works:
Code:void Init(int *n) { *n = 5; } int main() { int *i; i = malloc(sizeof(int)); Init(i); printf("%d", *i); getch(); return 0; }Leave a comment:
No activity results to display
Show More
Leave a comment: