c

What is the official way to call a function (C/C++) in ab. every 1/100 sec on Linux?

I have an asynchronous dataflow system written in C++. In dataflow architecture, the application is a set of component instances, which are initialized at startup, then they communicate each other with pre-defined messages. There is a component type called Pulsar, which provides "clock signal message" to other components which connect to...

Compare symbolic constant, enumeration, constant variable

symbolic constant- no type checking->the value is just substituted enumeration- more type safe than symbolic constant constant variables- most type safe Anything else that can be added here? Any difference in terms of space occupied by these? ...

Making UI for console application

How can I make an interface for console applications to make them look like edit.com under Microsoft's operating systems. Target languages are C, C++ and C#.NET. ...

How is it that main function is always loaded at the same address whereas variables have different address most of the time?

Hey guys! I wrote this small program today and I was blown away by the results. Here is the program int main(int argc, char **argv) { int a; printf("\n\tMain is located at: %p and the variable a is located at address: %p",main, return 0; } on my machine the main function is always loaded at address "0x80483d4" and the address of ...

Having trouble accessing struct elements returned by a function - dereferencing pointer to incomplete type

I am new to C.This are the files and codes that I am working on. I am trying to call a function (refineMatch) implemented in a separate file from the main function. function refineMatch returns a struct. I am having problems in compiling the code which is related to accessing elements in the returned struct. The compile error occurs in m...

C: pthread performance woes. How can I make this code perform as expected?

I have created this little program to calculate pi using probability and ratios. In order to make it run faster I decided to give multithreading with pthreads a shot. Unfortunately, even after doing much searching around I was unable to solve the problem I have in that when I run the threadFunc function, with one thread, whether that be ...

Divide an array into shorter arrays in C

Hi, in a C program I have this variable: float (*data)[3]; data = (float (*)[3])calloc(ntimes, sizeof(float[3])); which later is initialized. Afterwards I want to pass all the info in "data" to a serie of ntimes variables called "data_i" that I define with: typedef float (*el_i)[3]; el_i data_i[NTIMES]; // NTIMES is a constant with...

why "++x || ++y && ++z" calculate "++x" firstly ? however,Operator "&&" is higher than "||"

Why ++x || ++y && ++z calculate ++x firstly? However,Operator && is higher than ||? ...

Get interrupt counters like /proc/interrupts from code?

Hi, I may miss the obvious, but how/is it possible to retrieve interrupt counters for a specific interrupt without manually parsing /proc/interrupts from inside a C/C++ program? Thanks in advance! Best regards, Martin ...

Need help writing "backgroundless" widget for wxWidgets (wxGTK) using GTK2

Hi there. My question is concerned with GTK2 and wxWidgets (actually wxGTK). In wxGTK all controls have grey background by default and it is impossible to remove it. I have a textured panel with custom child controls and each of my controls has an ugly grey border which I can't remove. I can only set some background color and make the ...

How to judge whether a project is a c or c++ project?

wprintf(L"Selecting Audio Input Device: %s\n", varName.bstrVal); if(0 == wcscmp(varName.bstrVal, L"IP Camera [JPEG/MJPEG]")) { ... } hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pGrabberF); The above is from a .cpp file ,but a...

What are real significant cases when memcpy() is faster than memmove()?

The key difference between memcpy() and memmove() is that memmove() will work fine when source and destination overlap. When buffers surely don't overlap memcpy() is preferable since it's potentially faster. What bothers me is this potentially. Is it a microoptimization or are there real significant examples when memcpy() is faster so t...

What is IInternetProtocol->Start default implementation?

I have IInternetProtocol->Start method called and want to change HTTP request headers in there, but the rest of default implementation should be the same. ...

cuda app on part of the cards

I've got a Nvidia Tesla s2050; a host with a nvidia quadro card.CentOS 5.5 with CUDA 3.1 When i run cuda app, i wanna use 4 Tesla c-2050, but not including quadro on host in order not to lagging the whole performance while split the job by 5 equally.any way to implement this? ...

Solaris 10: handle gracefully ENOBUFS error when changing socket buffer

I have stumbled on a peculiar difference between Solaris 10 sockets and other Linux/*NIX sockets. Example: int temp1, rc; temp1 = 16*1024*1024; /* from config, a value greater than system limit */ rc = setsockopt( sd, SOL_SOCKET, SO_RCVBUF, &temp1, sizeof(temp1); The code above will have rc == 0 on all systems - Linux, HP-UX and AIX ...

Serial port loopback/duplex test, in Bash or C? (process substitution)

Hi all, I have a serial device set up as loopback (meaning it will simply echo back any character it receives), and I'd like to measure effective throughput speed. For this, I hoped I could use time, as in time bash -c '...' where '...' would be some command I could run. Now, the first problem is that I want to use the device at 2...

What's the purpose of a Header File?

Possible Duplicates: Why does C++ need a separate header file? In C++ why have header files and cpp files? Hi geeks, I have been using header files for almost everyday. It's kind of an instinct to me now. Suddenly, I ask myself, What on earth do we include a header file for? Currently, I think of the following reason: The...

How to return a complex return value?

Hi awesomes~ Currently I am writing some assembly language procedures. As some convention says, when I want to return some value to the caller, say an integer, I should return it in the EAX register. Now I am wondering what if I want to return a float, a double, an enum, or even a complex struct. How to return these type of values? I c...

How can I get the system language in C/C++?

How can I get the system language in C/C++? Like en_US or en_GB. ...

Is C really faster than C++?

At begning I used to believe, since C++ is superset of C, there should'nt be a reason for C++ being slower than C but many people on SO dont think so http://stackoverflow.com/questions/2245196/c-urban-myths/2245221#2245221. Is it true that C++ is slower than C? If not, why to use C anyway? ...