c

Working with processes in C

Hi, just a quick question regarding C and processes. In my program, I create another child process and use a two-directional pipe to communicate between the child and parent. The child calls execl() to run yet another program. My question is: I want the parent to wait n amount of seconds and then check if the program that the child has ...

Exclusive compute mode with OpenCL+NVidia

Hi, I have a question to exclusive compute mode with NVidia+OpenCL. I can set up exclusive compute mode (page 74 from cuda programming guide 3.0) with nvidia-smi on a nvidia-gpu . that means, only one program can compute on gpu. cuda runtime schedules than app automatically. but I have a problem with opencl-programs in this case: if o...

Searching a number in an array in least time

The elements of the array are arranged in non-decreasing order. I need to search the array for a given element in the least possible time. ...

how to call your yacc from a c file ?

i want to parse a command line using a yacc but i want to call it from a c file. how it is possible ? ...

How to convert actionscript code into c code?

Hi there, Can anybody suggest how to convert actionscript to c code? ...

Hiding Mouse Pointer on window Screen using GDI in c++

How to hide the mouse pointer on the window screen of GDI, kindly give me some hints. ...

Convert the ada code to its C .

I have a piece of ada code shown below which is a simple switch case statements.Is there any better way to convert this into C. for I in 1..100 loop case I is when 100 => Dollars := Dollars + 1; when 25|50|75 => Quarters := Quarters + 1; ...

Multithreaded program in C: calculating thread stack space

Situation: I am writing a program in C that maintains a number of threads. Once a thread ends, a new one is created. Each thread forks - the child runs a PHP process via exec() and the parent waits for it to finish. Each PHP process takes the next item from a queue, processes it and exits. Basic code: http://www.4pmp.com/2010/03/mu...

C signals and processes

Hi, so basically I want "cmd_limit" to take a number in seconds which is the maximum time we'll wait for the child process (safe to assume there's only one) to finish. If the child process does finish during the sleep, I want cmd_limit to return pass and not run the rest of the cmd_limit code. Could anyone help me do this, here's what I'...

How to find out if SCSI device (say /etc/sda) is a disk or not via ioctl calls or other ?

How to find out if SCSI device (say /dev/sda) is a disk or not via ioctl calls or other ? I have tried the following but the ioctl call fails. My /dev/sda is a USB flash disk. #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <scsi/scsi.h> #include <scsi/sg.h> #...

starting smartcard programming

How could one get started with smartcards programming? I am asking here about all the toolkit he needs in order to get started: books, tutorials, hardware etc. I am planning in playing around with a couple of smartcards programmers and I am pretty new to this field. Edit: I am mostly interested in programmers that play nice with Unix-l...

Best environment to port C/C++ code from Linux to Windows.

I'd like to make a big project of mine buildable on Windows platforms. The project itself it's written in C/C++ following POSIX standards, with some library dependencies such as libxml2, libcurl and so on. I'm more a Linux developer rather than a Windows developer, so i have no idea of which compiler suite i should use to port the code. ...

Using pthread condition variable with rwlock

Hello, I'm looking for a way to use pthread rwlock structure with conditions routines in C++. I have two questions: First: How is it possible and if we can't, why ? Second: Why current POSIX pthread have not implemented this behaviour ? To understand my purpose, I explain what will be my use: I've a producer-consumer model dealing ...

two threads going to do func()

2 threads going to use the same func(). The 2 threads should be mutually exclusive. How do I get it to work properly? (output should be "abcdeabcde") char arr[] = "ABCDE"; int len = 5; void func(){ for(int i = 0; i <len;i++) printf("%c,arr[i]); } ...

Why does this hex value get output as a negative number?

char buffer_b[5] = { 0xDA, 0x00, 0x04, 0x00, 0x07 }; printf("%d\n%d\n%d", buffer_b[0], buffer_b[2], buffer_b[4]); This gives me output: -38 4 7 However I am expecting: 218 4 7 Thanks. ...

How would you convert from ASCII to Hex by character in C?

I basically just want to take a 8 character ASCII value 003fc000 and convert it to Hex by character. ...

dereferencing pointer to incomplete type

I've seen a lot of questions on this but I'm going to ask the question differently without specific code. Is there a way of EASILY determining what is causing the type to be incomplete? In my case I'm using someone elses code and I'm completely sure I don't have the headers right, but (since computers do this stuff much faster and bett...

problems with searching in files and directories .. windows programming

Hi I'm studying this book (Addison Wesley Windows System Programming 4th Edition) and I think its useless Im working on a searching code that support the recursive so it can go in deepth in files and directories the code is working ( I guess ) no syntax error but the output is not what I want the out put of the search is like: not f...

Anonymous union definition/declaration in a macro GNU vs VS2008

I am attempting to alter an IAR specific header file for a lpc2138 so it can compile with Visual Studio 2008 (to enable compatible unit testing). My problem involves converting register definitions to be hardware independent (not at a memory address) The "IAR-safe macro" is: #define __IO_REG32_BIT(NAME, ADDRESS, ATTRIBUTE, BIT_STRUCT)...

Exception handling in Obj-C

I have been reading about exception handling on the Apple developer docs, but I was wondering why exceptions by standard C operations are not caught? E.g. the code below still crashes the application, without catching the div by zero. Will the @try/@catch block only catch Obj-C code? @try { int i = 10 / 0; } @catch (NSException * ...