c

Refresh a region in window before drawing text

I'm drawing text on window at WM_PAINT message, is there any way i can refresh that window region before drawing a new line of text so the old text at the same location would get erased? ...

In C how do you access a variable in a struct that's in a pointer array?

typedef struct { employeeT *employees; int nEmployees; } *payrollT; typedef struct { string name; } *employeeT; I need to do this without accessing it as an array: employeeT e = payroll.employees[i]; but this gives me an error(expected identifier before '(' token) : employeeT e = payroll.(*(employee+i)); before struc...

Which of the following would be more efficient?

In C: Lets say function "Myfuny()" has 50 line of codes in which other smaller functions also get called. Which one of the following code would be more efficient? void myfunction(long *a, long *b); int i; for(i=0;i<8;i++) myfunction(&a, &b); or myfunction(&a, &b); myfunction(&a, &b); myfunction(&a, &b); myfunction(&a, &b); myfunc...

Problem trying to use the C qsort function

#include <stdio.h> #include <stdlib.h> float values[] = { 4, 1, 10, 9, 2, 5, -1, -9, -2,10000,-0.05,-3,-1.1 }; int compare (const void * a, const void * b) { return ( (int) (*(float*)a - *(float*)b) ); } int main () { int i; qsort (values, 13, sizeof(float), compare); for (i = 0; i < 13; i++) { printf ("...

How to find how much space is allocated by a call to malloc()?

I'm trying to write a size function like this: size(void *p,int size); Which would return the size of an array which is pointed to by p. For example: Int *a = malloc((sizeof(int)*100)); size(a,sizeof(int)); // this should return 100 I think this is possible because if I recall, malloc keeps track of the space allocated in some head...

OpenCV - cvExtractSURF is causing a memory leak?

Hello OpenCV'ers, I am using the OpenCV function: cvExtractSURF but I am finding a major memory leak. Has anyone successfully implemented this call? My code is as follows: IplImage *cvImage = [self CreateIplImageFromUIImage:image grayscale:YES]; CvMemStorage* storage = cvCreateMemStorage(0); CvSeq *objectKeypoints = 0; //CvSeq *objec...

capture video from a built-in camera programatically

Hi, I was wandering how could capture video from the built-in camera of my netbook, under Linux, ubuntu. The programming language could is not an issue (but I prefer Java or the old school c) Thanks in advance for your answers, Gian ...

Trick Windows To See Second Monitor

Hi there, is there anyway to trick windows into thinking that a second monitor is connected to the computer, even if there isnt one? Example: Laptop also has an external screen connected into it. The external screen is the primary screen. When the screen is disconnected the laptop becomes primary even if the external screen is reconne...

What is the difference between "Real Types" and "Arithmetic Types" in C?

The C99 standard describes them as so: The integer and real floating types are collectively called real types. Integer and floating types are collectively called arithmetic types. Does this mean they're the same thing in C? Or are there any differences between them? ...

Update and multiple console windows

Hello; I want to write a simple c++/c console app, to show my process 1% 2%. for now, i print it line by line like "finsihed 1%" "finished 2%" and etc how can i just update percentage x% without printing a new line? and i want to open two console windows one show messages one show the process as above. how do i open another console ...

GtkButton just shows text but no image

Hi, I have a GtkButton inside a GtkHButtonBox that doesn't show the image I'm adding to it. It just shows the text. Here's the code: GtkImage *image = (GtkImage *) gtk_image_new_from_file("Gateway-LT21-netbook-2-540x359"); GtkButton *button = (GtkButton *) gtk_button_new_with_label("test"); gtk_button_set_image(button, (GtkWidget *) i...

Rewrite in place - stdout.

Because I'm currently setting up a new server for use, I've been using a lot of command-line programs like curl and wget, and I've noticed that they do something interesting. When run in the Terminal, they print their current progress in place (e.g. 54% will become 55% in place, instead of 55% being printed on the next line - download a ...

Double pointers are also sometimes employed to pass pointers to functions by reference

" Double pointers are also sometimes employed to pass pointers to functions by reference " can somebody can explain me the above statement, what exactly does point to function by reference means ? ...

moving of disc in tower of hanoi

Please explain to me the recursion process step by step using F7. I just can't correlate the return with flow of control. #include<stdio.h> #include<conio.h> void t_of_h(char, char, char, int); void main() { int n; clrscr(); printf("Enter no of DISC in Tower of Hanoi : "); scanf("%d",&n); printf("\nTower of Hano...

expected specifier-qualifier-list before

I have this struct type definition: typedef struct { char *key; long canTag; long canSet; long allowMultiple; confType *next; } confType; When compiling, gcc throws this error: conf.c:6: error: expected specifier-qualifier-list before ‘confType’ What does this mean? It doesn't seem related to other questions wit...

socket programing using operating system "solaris 10" and framework sun studio

any one help me that in this matter. my program can not run. code to bind the socket which i write is: char sendbuf[5]={"\0"}; unsigned int iMsgCode=1; unsigned int iServiceID=3; short int iAliveStatus=1; memcpy(sendbuf,&iMsgCode,2); memcpy(sendbuf+2,&iServiceID,2); memcpy(sendbuf+4,&iAliveStatus,1); char broadcast = '1'; int numbyte...

Problem with omp_set_num_threads called from a WinAPI thread

I've run into a funny problem using OpenMP v2 under MSVC 9 SP1. when calling omp_set_num_threads from the main thread of execution then using omp_get_num_threads to check the amount set, all works well and checks out. However, in an GUI app, I call the same thing, but its own thread(created with CreateThread), to prevent the UI from be...

Ending char* vector in c

How do I mark the end of a char* vector with '\0' to null-terminate it? If i have char* vector: char* param[5]; I thought of either param[4] = '\0'; or char c = '\0'; param[4] = &c; but none of them seem to work? param is a char-pointer vector, supposed to point to 5 strings(char-vectors). ...

Face Detection Library with C/C++ interface.

Can you please point me to library(ies) for face detection (NO RECOGNITION NEEDED!)? Any good-working libraries except OpenCV(!!!). Preferably free of charge - open source is not required. ...

How to check the status between 2 servers ?

There are 2 servers, they need to know the status(live oe dead) each other. my method is a long tcp connecting, Is there any better method? thanks. ...