c

Need help on determining segementation fault occuring in loop?

On running the following script, I get segmentation fault. The output consists of "here 5a". But nothing beyond it. Any suggestions on what might be going wrong? if(model==1) fptr3=fopen("poisson.pro","r"); if(model==2) fptr3=fopen("jtt.pro","r"); if(model==3) fptr3=fopen("estimate.pro","r"); printf ("here 5a\n"); for (i=0;i<20...

Listing and finding windows on OS X

I am trying to do some stuff on OS X using the carbon api, but I can't find anything I am looking for on google or the Apple development website. Ideally I would like to find a function that finds the window at a certain location on screen. It seems that there are similar functions, but one of them says that it only finds windows in th...

What c preprocessor macros have already been defined, gcc?

In gcc, wow can I check what C preprocessor definitions are in place during the compilation of a C program, in particular what standard or platform-specific macrodefinitions are defined? ...

mmaping large files(for persistent large arrays)

Hello! I'm implementing persistent large constant arrays via mmap. Is there any tips and tricks or gotchas one should be aware when using mmap? ...

What is a Thread-pool?

What is the concept of implementing Thread-pool (in C with help from pthreads)? how can a thread be assigned to execute from the thread pool ? ...

web application image processing

I'm writing a web application whose sole intention is to process the images provided by the user. I do understand that a multitude of programming languages facilitate server-side image manipulation and some basic functionality etc., but my concern here is which might be the best programming language/ libraries for exhaustive image proce...

Is this a good error reporting solution for an embedded C app?

Based on the answers to a previous question, here's a design for a simple error reporting system for my embedded C app. I'd appreciate some feedback. My app has code forming an overall program plus several layers of lower-level libraries. At the lowest level, the library gets a byte to use for error codes, so 255 total errors. They'll b...

CreateDesktop() with Vista UAC (C Windows)

I'm using CreateDesktop() to create a temporary desktop where an application will run, perform a cleanup action (while remaining out of the way) and terminate. I'm closing that desktop once the application is gone. Everything is fine when using Windows XP and even Vista. The problem arises when you enable the (annoying) UAC. Everything ...

Getting Filename from file descriptor in C

Is it possible to get the filename of a file descriptor in C? ...

Hpux telnet using socket

o Sun OS, UTS, AIX etc. But, when the same program is run with HP UX on the other end, we are unable to receive the response from the HP UX box (B.11.31 O/S). sSocket = socket(AF_INET,SOCK_STREAM,0); connect(sSocket,(struct sockaddr *)&sin,sizeof(sin); ierr = read(sSocket,szBuffer,BUF_LEN-1); When the read is called, we get jun...

How can I monitor status changes of windows services under windows xp?

I'm trying to write a program in C, that can detect when some Windows services (aka. NT services) are started or stopped. There seems to be a function NotifyServiceStatusChange, but that's only available on Vista and Windows 7. I'm trying to do this on Win XP, so what's the best way? Is there any other than continuous polling? edit: I...

Hide a file or directory using the Windows API from C

I want to modify a C program to make some of the files it creates hidden in Windows. What Windows or (even better) POSIX API will set the hidden file attribute? ...

Strange Eclipse C++ #define behaviour (resolved)

(A case of over relying on an IDE) I have some legacy C code that I compile as C++ for the purpose of Unit testing. The C source is C++ aware in that it conditionally defines based on environment. E.g. (PRIVATE resolves to static): #if!defined __cplusplus #define PRIVATE1 PRIVATE #endif ... PRIVATE1 const int some_var; The proble...

Problem with rand() in C

Possible Duplicate: why do i always get the same sequence of random numbers with rand() ? This is my file so far: #include <stdio.h> int main(void) { int y; y = generateRandomNumber(); printf("\nThe number is: %d\n", y); return 0; } int generateRandomNumber(void) { int x; x = rand(); return x; } ...

I need to generate random numbers in C

Possible Duplicates: How to generate a random number in C? implementation of rand() Generating random terrain in Blender3D I need high quality random numbers in C, but I have no idea what to really do. I need to be able to get numbers from 1-100. Any help or maybe point me to where I can find help. ...

When are -framework and -I/System/.../Example.framework/Headers/ needed?

I am trying to compile a JNI library which uses carbon from the command line. If I don't -I/System/.../JavaVM.Framework/Headers/, It can't find any of the jni types, and gives errors. If I just -I/System/.../FlatCarbon.framework/Headers but don't "-framework Carbon", it compiles fine, but the linker gives an error about an undefined sy...

How to parse a URL in C?

Hi, Im wondering how to parse a url into an URL object(of some kind) in C. So that I would be able to extract key/val objects from a querystring. Have looked at: http://stackoverflow.com/questions/726122/best-ways-of-parsing-a-url-using-c And several other resources, even Google Code, but haven't found anything in my taste.. And no, u...

Swap bits in a number in C.

In a C interview, I was asked to swap the first 4-bits of a number with the last 4 bit. (eg. 1011 1110 should be 1110 1011.) Does anyone have a solution for this? ...

Looking for lightweight document description language for printing

I'm looking for a very lightweight document description language, which can be easyly parsed in C. The purpose is printing of small documents or labels similar to cash register receipts. I need only basic formatting features for font settings, alignment and insertion of predefined variables. Any ideas? Would using of some subset of rtf ...

Why segfault on fclose?

I'm clearly missing something. Could someone please explain why this would happen? #define RANDOM_DEVICE "/dev/random" int create_shared_secret(char * secret,int size) { FILE * file=NULL; int RetVal; file=fopen(RANDOM_DEVICE,"r"); if(!file) { printf("Unable to open random device %s\n",RANDOM_DEVICE); exit(-1); } R...