c

Windows message when mouse leave a control?

I have created a control and the mosemove for that control makes it change color, but I want to change it back to default when my mouse moves out of that control. I would have thought WM_MOUSELEAVE would do it but it didn't. Thanks ...

Gradients for polygons in OpenGL

what is the best way to create a gradient for a 2D polygon in OpenGL, (Linear, and Radial)? Thanks How can you generate textures for radial gradients on the fly? ...

Are timers supported by Windows Native API?

Do Windows Native API support Timers? I am aware that POSIX implementations on Windows support timer, but I am interested in Windows SDK APIs. ...

How communicate with pty via minicom or screen?

I am trying to provide an AT/Modem-like interface around some hardware. Follwing this post I have the server setting up a pty using openpty(). Now I can communicate with the server as expected with a client app that open the slave and communicates via read() and write() calls. However I would also like to be able to use either the scre...

Read and write directly from and to compressed files in C

Hi, in Java I think it is possible to cruise through jar files like they were not compressed. Is there some similar (and portable) thing in C/C++ ? I would like to import binary data into memory from a large (zipped or similar) file without decompressing to disk first and afterwards writing to disk in a compressed way. Maybe some tr...

How to test is a string is initialized in c?

Quick and easy C question: char* foo How can I test if foo hasn't still been assigned a value? Thanks. ...

linking error on MAC OS

Hi everybody, I am little new to MAC os but while building an cpp application on MAC OS X , using g++ I am getting strange error from linker. first at one step I am creating a library using several object files generated from cpp source and then I am creating a single archive using ar rvs command. If I am linking this library to anot...

win32 - How do I capture a screen as an 8-bit or 16-bit bitmap?

I am just starting out with win32 GDI programming and finding good references hard to come by. I have a simple application that captures the screen by doing the following: UINT32 x,y; x = GetSystemMetrics(SM_CXSCREEN); y = GetSystemMetrics(SM_CYSCREEN); HDC hdc = GetDC(NULL); HDC hdcScreen = CreateCompatibleDC(hdc); HBITMAP hbmp = C...

PHP: How To Call Standard Library Functions

Hi, I'm starting with PHP for dynamic web pages. I have some libaries written in ANSI C for getting/setting parameters and other proprietary stuff. I wonder, is there a simple solution to use a wrapper inside PHP to call this funtions? Is there a already existing class/library? What would be the best practice to do this on my own? I don...

Stepping Over in Emacs GDB

I'm having some trouble stepping over in GDB. I've built an example program from the ffmpeg library with debug symbols on and stripping off. Although I configured the ffmpeg library to static and explicitly disabled shared, it looks like the program I'm debugging is linking dynamically, since its file size is only 99kB. I don't know t...

Help me understand this C code

INT GetTree (HWND hWnd, HTREEITEM hItem, HKEY *pRoot, TCHAR *pszKey, INT nMax) { TV_ITEM tvi; TCHAR szName[256]; HTREEITEM hParent; HWND hwndTV = GetDlgItem (hWnd, ID_TREEV); memset (&tvi, 0, sizeof (tvi)); hParent = TreeView_GetParent (hwndTV, hItem); if (hParent) { // Get the parent ...

arff FileReader class in C

Hi guys, need your help. I actually don't know how to extract dates from a arff-file. arff-file: @ATTRIBUTE a1 NUMERIC @ATTRIBUTE a2 NUMERIC @ATTRIBUTE a3 {a,b,c,d,e} @DATA 12.5,1,b 3.7,2,a 3.5,1,c ... do C have BufferedReader and InputStreams? Thanks a lot! ...

Function pointer with default parameter in C.

See, I have two functions, one to get a char, and other to put a char like this. void function_get_char (input); void function_put_char (output); I have a function pointer to these functions like this. void (*function_operators[])(input_or_output) = {function_get_char, function_put_char}; I need of, when I'll call my function_opera...

Demystifying gcc under lpthreads

in these i'm playing with thread library and trying to implement some functions. One of the tutorial says that to run the program use : gcc -lpthread -lrt -lc -lm project1.c scheduler.c -o out first of all i need deep understanding of what is gcc doing in each line, lpthread is used for what? what are the contributions of lrt -lc -l...

Can I Always debug multiple instances of a same object that is of type thread with GDB?

program runs fine. When I put a breakpoint a segmentation fault is generated. Is it me or GDB? At run time this never happens and if I instantiate only one object then no problems. Im using QtCreator on ubuntu x86_64 karmic koala. UPDATE1: I have made a small program containing a simplified version of that class. You can download ...

How to find coordinates of a 2d equilateral triangle in C ?

Hello, I have the coordinates (x,y) of 2 points. I want to build the third point so that these 3 points make an equilateral triangle. How can I calculate the third point? Thank you ...

Comparing a peer's IPv6 address with localhost

I have called getpeername on my connected socket and now have an IPv6 address of the connected peer. How do I tell whether my peer's IP address is localhost? Edit: To clarify, I mean specifically localhost, as in the loopback IP address. ...

Mmap and structure

I'm working some code including communication between processes, using semaphores. I made structure like this: typedef struct container { sem_t resource, mutex; int counter; } container; and use in that way (in main app and the same in subordinate processes) container *memory; shm_unlink("MYSHM"); //just in case fd = shm_ope...

How large should my recv buffer be when calling recv in the socket library

Hi, I have a few questions about the socket library in C. Here is a snippet of code I'll refer to in my questions. char recv_buffer[3000]; recv(socket, recv_buffer, 3000, 0); First, How do I decide how big to make recv_buffer? I'm using 3000, but it's arbitrary. Second, what happens if recv() receives a packet bigger than my recv_...

Free object/widget in GTK?

I've got a pack box in my GTK application and I'm replacing it every once in a while with a completely new entry (at least for now cause I'm in a hurry). Since I'm replacing it with a new instance, do I need to explicitly free from memory the old pack box contents or is there some garbage collection in GTK? If I do need to explicitly n...