c

C library equivalent to Visual in VPython?

I'm looking for a simple C 3D library that is similar to Visual in VPython. Ideally, I can describe objects and position them and then change the camera view, etc. Simple usage is important. In a way, it would be similar to retained mode in D3D... Thanks. ...

How to set up a cron job to run an executable every hour?

I need to set up a cron job that runs an executable compiled using gcc once every hour. I logged in as root and typed crontab -e Then I entered the following and saved the file. 0 * * * * /path_to_executable However, the cron job does not work. I see that when I type /...path_to_executable I get a segmentation fault. I can only ex...

How to make GCC output to stdout?

GCC is normally instructed to output to a file via the -o switch. If this isn't provided it seems to decide on an appropriate name and output to that. How do I make GCC write its generated output to stdout? ...

where and when do the global static and local static get stored and initialized?

Hi, #include <stdio.h> static int i = 10; int main() { static int i = 20; printf ( "i = %d\n", i ); return 0; } There are two static variables, one in global scope and one in function scope. The compiler is not throwing "multiple definition" error. Could you please let me know where the two static vars are stored? ...

Light C data structures and strings library?

I'm searching for something on the level of GNU extensions for C, but a little beyond (some basic data structure management). Best would be something BSD/MIT licensed. If there is something for just strings containing GNU extensions equivalents plus adding some more it would be great. I would prefer something that can be simply compile...

Run C program on windows written in Linux

I have c project which is written in linux. It runs on linux very well. But now I want to run it on windows. I want to know best and easy ways to run it on windows. ...

Take screenshot of desktop when Windows is locked (Win+L)

I want to take a screenshot of desktop while Windows is locked (with Win+L). Standard methods make a black screen, with code of pixel: COLORREF color = GetPixel(hdc, x, y); equal -1. Neither a user mode program nor a service could capture a useful image. Any ideas? ...

Over reliance on macros

I feel, every time I read a C or C++ program, that half or more of it is just macros. I understand that macros can be cool but they are hard to track, debug, etc. Not to mention that most programming languages do not even define something like macros (although Perl6 will have something of the sort). I personally always have found a way ...

Callback without function pointer

Hi, It is usually said callbacks are implemented with function pointers. When I check PortAudio's source code, I see that callback function is declared as an ordinary function (not a f. pointer). Is it normal/legal/advisable? typedef int PaStreamCallback( const void *input, void *output, unsigned long frameCount, const PaStreamCallbackT...

Vim different textwidth for multiline C comments?

In our C++ code base we keep 99 column lines but 79-some-odd column multiline comments. Is there a good strategy to do this automagically? I assume the modes are already known because of smart comment line-joining and leading * insertion. ...

Execute program from within a C program

How do I run another program from within my C program, I need to be able to write data into STDIN(while execution of program i have to provide input through stdin more than once) of the programed launched (and read line by line from it's STDOUT) I need the solution to work under Linux. while going through net i found below code: #inc...

Need Exercise to solve based on Linear Linked List

I have completed implementing Operation of Linear Linked List using C, Now inorder to test my ability i need to solve some problems based on Linear Linked List, and there you people can help me by suggesting some problems/assignments ... I think there is nothing wrong in asking this type of help from my community members . ...

POSIX API call to list all the pthreads running in a process

I have a multi-threaded application in a POSIX/Linux environment - I have no control over the code that creates the pthreads. At some point the process - owner of the pthreads - receives a signal. The handler of that signal should abort,cancel or stop all the pthreads and log how many pthreads where running. My problem is that I could ...

Execute another C program from within a C program

How do I run another program from within my C program, I need to be able to write data into STDIN(while execution of program i have to provide input through stdin more than once) of the programed launched (and read line by line from it's STDOUT) I need the solution to work under Linux. While going through net I found below code: #inc...

Replacing ld with gold - any experience?

Has anyone tried to use gold instead of ld? gold promises to be much faster than ld, so it may help speeding up test cycles for large C++ applications, but can it be used as drop-in replacement for ld? Can gcc/g++ directly call gold.? Are there any know bugs or problems? Although gold is part of the GNU binutils since a while, I have...

Function pointer to function returning Multidimensional array

Hi, With respect to this question, we can declare a function that returns pointer to array as: int (*function())[3] which returns Ax3 array, ok. How is the proper way to declare a function pointer that points this kind of function? ...

How to use 12 digit number in C ?

I am dealing with a math example. I need to use 12 digit number for my code. So which datatype should i use, to use the number in my functions? ...

How does realloc know how much to copy?

Hey, how does realloc know the size of original data? void *realloc(void *ptr, size_t size); So, if the implementation is like this: temp = malloc(size); memcpy(.. // How much to copy? free(ptr); return temp; I realize this is not the original implementation, and realloc doesn't always do free, but when it does, how much does...

How to perform sequential file write in separate thread

I am given some data in a callback function to write to disk sequentially, about 4KB every 0.02 seconds. If I fwrite() from the thread the callback function is in, I get some lag in other parts of code in same thread. So in order to not block this thread while writing to disk, I want to move the fwrite code to another thread. The problem...

Would it break the language or existing code if we'd add safe signed/unsigned compares to C/C++?

After reading this question on signed/unsigned compares (they come up every couple of days I'd say): http://stackoverflow.com/questions/3475841/signed-unsigned-comparison-and-wall I wondered why we don't have proper signed unsigned compares and instead this horrible mess? Take the output from this small program: #include <stdio.h>...