c

Retrieve and store elements (according to conditions) from an array.

Given an array of 81 elements (meant to represent a 9x9 grid) how can I go over each element, grabbing the three around it and then performing an operation on those, then continuing to the next three of each row, column, or submatrix. Look below or at a sudoku grid to see the layout. define COL(n) ((n) % 9) define ROW(n) ((n)...

Box-and-circle diagram of a double pointer?

Does anyone have a link to a box-and-circle diagram of a double pointer? ...

gethostbyname win32 error...

Hi all, I am using the gethostbyname() function in the usual manner... iaHost.s_addr = inet_addr(lpServerName); if (iaHost.s_addr == INADDR_NONE) { // Wasn't an IP address string, assume it is a name lpHostEntry = 0; lpHostEntry = gethostbyname(lpServerName); } to access my web site and return information. The variable, "lpServer...

Are threading issues for C/C++ "system level programmers" significantly different from those faced by Java programmers?

I'm looking for a development job and see that many listings specify that the developers must be versed in multithreading. This appears both for Java job listings, and for C++ listings that involve "system programming" on UNIX. In the past few years I have been working with Java and using its various synchronization mechanisms. In the...

C: pattern for returning asynchron error from background thread?

I'm writing an open source C library. This library is quite complex, and some operations can take a long time. I therefore created a background thread which manages the long-running tasks. My problem is that I have not yet found an elegant way to return errors from the background thread. Suppose the background thread reorganizes a file ...

C/C++ Windows traffic blocker

I want to develop a bandwidth allocator to a network which will be behind my machine. Now, I've read about NDIS but I am not sure whether the network traffic that is neither originating from my machine nor is destined for my machine will enter my TCP/IP stack, so that I can block/unblock packets via NDIS on a windows machine. ...

I2C ISR and Interrupts

Platform - ARM9 I have a third party device connected via I2C to the ARM9. My problem is the I2C read/write is getting in a twist. It appears the IRQ line is asserted but never de-asserted when there is data to read. The read fails as the third-party device NACKs the address packet. So any subsequent write fails. I am wondering if my i...

How do I know if gcc agrees that something is volatile?

Consider the following: volatile uint32_t i; How do I know if gcc did or did not treat i as volatile? It would be declared as such because no nearby code is going to modify it, and modification of it is likely due to some interrupt. I am not the world's worst assembly programmer, but I play one on TV. Can someone help me to understan...

regular expression help with converting exp1^exp2 to pow(exp1, exp2)

I am converting some matlab code to C, currently I have some lines that have powers using the ^, which is rather easy to do with something along the lines \(?(\w*)\)?\^\(?(\w*)\)? works fine for converting (glambda)^(galpha),using the sub routine in python pattern.sub(pow(\g<1>,\g<2>),'(glambda)^(galpha)') My problem comes with nested ...

Sending string (of characters) to active window

I wrote a simple program that reads the characters from external device (bar code scanner) from serial port (/dev/ttyS1) and feeds it to the currently active window (using XSendEvent). Program works fine on faster computers, but on slow ones the situation happens (very often) that characters don't get received in the same order they wer...

Is there some kind of memory limit for an executable (written in C) to run without problems?

i´m doing a project using C, and CodeBlocks is my IDE. Windows Vista is the OS. I added some new stuff to the already working code and now the executable crashes everytime. i have no errors after compiling though. Computers and programming is not my field, but i suspect it may have something to do with some kind of memory limitations (if...

Converting a pthreaded program to MPI?

I understand the differences between a multithreaded program and a program relying on inter-machine communication. My problem is that I have a nice multithreaded program written in 'C' that works and runs really well on an 8-core machine. There is now opportunity to port this program to a cluster to gain access to more cores. Is it wo...

Query on Select System Call

select() is defined as : int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout); nfds represents the highest file descriptor in all given sets plus one. I would like to know why is this data required for select() when the fd_set information is available. If the FDs in the set are say, 4, 8...

Floating point rounding when truncating

This is probably a question for an x86 FPU expert: I am trying to write a function which generates a random floating point value in the range [min,max]. The problem is that my generator algorithm (the floating-point Mersenne Twister, if you're curious) only returns values in the range [1,2) - ie, I want an inclusive upper bound, but my...

What is the best Evaluation Kit for Learning Embedded C/C++ Development?

I am trying to improve my embedded C/C++ development on ARM architecture. I have recently moved from 68K development to ARM and wanted to use some of my spare time to dig into the platform and learn the best practices especially on developing for mobile platforms. Preferably 32bit architecture will be helpful with supporting development...

C system() call fails with error "unterminated string".

I have a small piece of c code which should run an awk command on my linux machine. However for the life of me it will not exec. The awk works if I directly run it in the terminal. My current failed command system("awk '{ printf \"%d \n\", $12 }' results.dat | sort -n"); It fails with awk: { printf "%d awk: ^ unterminated...

Good IDE/compiler for simple C dll's.

I'm trying to disassemble a C/C++ DLL, and have made some progress, but I would like to create my own C DLL with the same function the original exports, and compare disassemblies. Visual Studio adds to much crap, and when I remove the crap and build my project, the expected DLL is missing. I need a lightweight, preferably IDE, tool to ...

Distributing loadable builtin bash modules

I've written a built-in for bash which modifies the 'cd' command, a requirement for my software. Is there a way to actually distribute a loadable independently of bash itself? I'd ideally like to distribute just a drop in "additional feature" because I know people can be put off by patching and compiling their shell from source code. ...

implementation for product keys

Hi there, I'm implementing a small application in C, which I would like to sell as shareware for a reasonable price later on. It will start of with a 30-day trial, which I am already quite certain of how to implement it. The problem I have, though, is that I am not quite sure how to implement the product key verification. What I have i...

C: Run a System Command and Get Output?

hi, i want to run a command in linux, and get the text returned of what it outputs...but i DO NOT want this text printed to screen. There has to be a more elegant way than making a temporary file right? Duplicate of http://stackoverflow.com/questions/43116/how-can-i-run-an-external-program-from-c-and-parse-its-output ...