c

Does this sound like a stack overflow?

I think I might be having a stack overflow problem or something similar in my embedded firmware code. I am a new programmer and have never dealt with a SO so I'm not sure if that is what's happening or not. The firmware controls a device with a wheel that has magnets evenly spaced around it and the board has a hall effect sensor that se...

NSString stringWithFormat: with C array?

Hi, I'm writing a program that calculates the Jacobi algorithm. It's written in Objective-C since it runs on a Mac, but the majority is written in standard C. I'm using a two-dimensional C array and an NSArray containing 5 NSTextField labels. The following code yields an EXC_BAD_ACCESS error: for ( int i = 0; i < 5; i++ ) { NSStr...

changing command line arguments

Hi, I am writing a C program. It takes its arguments from commandLine. I want to change the commandLine arguments in the code. As they are defined as "const char *", I can not change them using "strcpy", "memcpy", ... Also, you know, I can not just change their type from "const char *" to "char *". Is there any way to change them? Tha...

How would I go about writing a Linux TTY sniffer?

For educational purposes (not that anyone should care about the motivations behind such an exercise) I'd like to write a program that can read/write to/from alternate tty/pty's. I've read papers (from the 1990's) but can't employ the implementation they use, on modern Linux/glibc I was hoping that someone had researched into this in the...

Glob function (c) and backup file (file~)

I'm using glob function for a autocompletion function. I'm showing you the problem because it's difficult to explain: matched = ~/.tcsh glob(matched, 0, NULL, &pglob); glob put all matched files in a char ** and when I print it I have: case[0] = .tcshrc case[1] = I should have .tcshrc~ in case[1], but nothing =S, I've seen a flag ...

How to optimize Dijkstra algorithm for a single shortest path between 2 nodes?

Hi, I was trying to understand this implementation in C of the Dijkstra algorithm and at the same time modify it so that only the shortest path between 2 specific nodes (source and destination) is found. However, I don't know exactly what do to. The way I see it, there's nothing much to do, I can't seem to change d[] or prev[] cause th...

C-library consists of asynchronous DNS resolver

Need to find a asynchronous DNS resolver implemented in C (except Sofia Resolver) which supports DNS queries for NAPTR, SRV and A records. It would be desired to support internal caching. Any suggestions/recommendations? Currently looking at ldns which supports NAPTR, SVC and A queries. But, If I have understood correctly, it is not asyn...

gametutorials.com questions and reviews DirectX tutorials

Just curious to know if anyone has ever used gametutorials.com products for learning directX. I was debating on whether I should buy it or not. I read online that most of his tutorials were written in the source code. It's nice to heavily comment your code but if most of the tutorial is in his code then I don't think that is necessarily ...

Big problem with Dijkstra algorithm in a linked list graph implementation

Hi, I have my graph implemented with linked lists, for both vertices and edges and that is becoming an issue for the Dijkstra algorithm. As I said on a previous question, I'm converting this code that uses an adjacency matrix to work with my graph implementation. The problem is that when I find the minimum value I get an array index. T...

Is there a limit of stack size of a process in linux

Hi, Is there a limit of stack size of a process in linux? Or it depends on the RAM of the machine? I asked because I want to know how many deep of recursive I can call? Thank you. ...

opengl invert framebuffer pixels

I was wondering was the best way to invert the color pixels in the frame buffer is. I know it's possible to do with glReadPixels() and glDrawPixels() but the performance hit of those calls is pretty big. Basically, what I'm trying to do is have an inverted color cross-hair which is always visible no matter what's behind it. For instance...

Execution output to text file

Hi all, I am writing a C program using Visual Studio 2008. I use F7 to compile and F5 to execute the program.When I press F5 an execution window contains the output. But I want the output to get saved to a text file. How to do this in visual studio. Please help me someone. ...

Returning c_str from a function

This is from a small library that I found online: const char* GetHandStateBrief(const PostFlopState* state) { static std::ostringstream out; ... rest of the function ... return out.str().c_str() Now in my code I am doing this: const char *d = GetHandStateBrief(&post); std::cout<< d << std::endl; Now, at first d contained ga...

Passing arguments to a C program

Hi All, I was writing a C program where I use 6 variables a,b,c,d,e,f a,b,c are constant values which I should pass as an arguments from the command line. d,e,f are going to be size of arrays of a structure. typedef struct { blah blah } ex; ex ex0[d]; I am very confused about how to pass all these as argument. Right now I have ...

C doubt regarding array of pointers please explain

Why do we use static with array of pointers? What is the relation between static and array of pointers? For example: main() { int a[]={1,2,3}; int *p[]={a,a+1,a+2}; ...... } This code shows illegal initialization - why? Whereas the following code works: main() { static int a[]={1,2,3}; static int *p[]={a,a+1,a+2}; ...

C linux equivalent of windows QueryPerformanceCounter

Is there an equivalent C function in linux for reading the CPU counter and its frequency? I am looking for something similair to QueryPerformanceCounter function that reads the 64bit counter in modern CPU's ...

CMake and BLAS for a C program

I'm trying to use CMake to build a program relying on blas, I'm detecting blas using : include (${CMAKE_ROOT}/Modules/FindBLAS.cmake) The problem is, FindBLAS require a fortran compiler and complain with -- Looking for BLAS... - NOT found (Fortran not enabled) As blas is already installed on my machine (ATLAS Blas), and gfortran is...

Passing parameter to pthread

Hello, i have the following code: #include <stdlib.h> #include <stdio.h> #include <pthread.h> #define NUM_THREADS 100 struct thread_param { char *f1; char *f2; int x; }; void *thread_function(void *arg){ printf("%d\n", ((struct thread_param*)arg)->x); } int main(int argc, char *argvs[]){ int i, thread_cr_res = 0,...

Information on Rojiani's Numerical methods C textbook

Hi, having taken a look at a few textbooks that discuss numerical methods and C programming, I was gladly surprised when browsing through "programming in C with numerical methods for engineers" by Rojiani. I understand of course it's important that one need to have a solid background in numerical methods prior to try implementing them on...

GdkEventKey. Key value question

Hi How to translate GdkEventKey.keyval with level > 0 to key value with level == 0? For example: GDK_ISO_Left_Tab ==> GDK_Tab? Of course not using switch/case for every key. I need to get particular key, not a character. ...