c

how to find the location of the executable in C

Is there a way in C/C++ to find the location (full path) of the current executed program (the problem with argv[0] is that it does not give the full path). Thanks. ...

Where can I find an implementation of C99's math for Visual Studio?

I have some code that uses several math functions that exist in C99, but aren't defined in math.h or cmath that come with VS2005. Anywhere I can get a VS2005 compatible implementation of C99? ...

XML signature verification library in C ...

Are there any available libraries in C language to verify XML signatures ? , I could only find one library for C++ from http://santuario.apache.org/c/index.html. ...

How to tell the preprocessor to search for a particular folder for header files, when I say #include <xyz.h>

I have around 120 header files(.h files) , and in all of them each one includes many other header files using #include , but as I kept .h files in a specific folder, preprocessor is generating filenotfound error. I moved all the .h files to the single .C file that is calling the first headerfile. One way to do is make #include as #inc...

Hash function to matrix

I have two matrices and I need to compare them, but I don't want to compare position by position, I think that is not the best way. I thought of hash functions, does anyone know how to calculate the hash of a matrix? ...

JNA Passing Structure By Reference Help

Hi all, I'm trying to use JNA to talk over a USB device plugged into the computer. Using Java and a .dll that was provided to me. I am having trouble with the Write function: C code: typedef struct { unsigned int id; unsigned int timestamp; unsigned char flags; unsigned char len; unsigned char data[16]; } CANMsg; ...

JNI Calls different in C vs C++?

Hey Folks, So i have the following code in C that utilizes Java Native Interface however i would like to convert this to C++ but am not sure how. #include <jni.h> #include <stdio.h> #include "InstanceMethodCall.h" JNIEXPORT void JNICALL Java_InstanceMethodCall_nativeMethod(JNIEnv *env, jobject obj) { jclass cls = (*env)->G...

At what point does the segfault occur?

Does the following code segault at array[10] = 22 or array[9999] = 22? I'm just trying to figure out if the whole code would execute before it seg faults. (in the C language). #include <stdio.h> int main(){ int array[10]; int i; for(i=0; i<9999; ++i){ array[i] = 22; } return 0; } ...

For loop missing several indexes with segfault

The output of the application (bottom) is as follows: Element index number: 0 Element contents: 22 Element index number: 1 Element contents: 22 Element index number: 2 Element contents: 22 Element index number: 3 Element contents: 22 Element index number: 4 Element contents: 22 Element index number: 22 Element contents: 134513712 Why...

fopen non-ascii character error

i cannot use fopen on files includes in their name some characters (example : ş, ç, ı) how can i use fopen on these files ? i'm using vc++ 6 (i have to) and c language. when i was trying to use _wfopen it's never open any file. ...

How to read and write extended windows file attributes with win32

Hi, I would like to embed some meta data in a windows file. I came across the concept of extended file attributes, which I believe are used for this very purpose. For example, camera name in jpgs, episode name in avis. Apart from some very obscure non-documented kernel APIs, I cannot find how to do this in c/c++ using the win32 api. ...

Pthread - What is the difference between time.h::sleep() and pthread.h::pthread_yield()?

I spent a good long while looking for info on the differences between time.h::sleep() and pthread.h::pthread_yield() but was unable to find any solid reference material and so I am posting this question. What is the difference between time.h::sleep() and pthread.h::pthread_yield()? Update: The reason I ask is because I was using sleep...

Signal safe use of sem_wait()/sem_post()

I am trying to create a wrapper on Linux which controls how many concurrent executions of something are allowed at once. To do so, I am using a system wide counting semaphore. I create the semaphore, do a sem_wait(), launch the child process and then do a sem_post() when the child terminates. That is fine. The problem is how to safel...

C - Improper Pointer/Integer Combination in strftime()

I'm getting the compiler error: (83) error: improper pointer/integer combination: arg #1. Here's the code that is doing it: char boot_time[BUFSIZ]; ... Line 83: strftime(boot_time, sizeof(boot_time), "%b %e %H:%M", localtime(table[0].time)); where table is a struct and time is a time_t member. I read that "improper pointer/integ...

Matching order in PCRE

Hello, How can I set which order to match things in a PCRE regular expression? I have a dynamic regular expression that a user can supply that is used to extract two values from a string and stores them in two strings. However, there are cases where the two values can be in the string in reverse order, so the first (\w+) or whatever ne...

How to random seed from memory usage?

In windows, I want to generate random number with seed: time + memory usage. I want to get the memory usage from physical memory sytem cache the one that appears in taskmgr. So, How to get physical memory system cache in c (windows and not .net )? The random seed may end up something like this: srand((unsigned int)(time(0)+ memSystemC...

Implementing Semaphores, locks and condition variables

I wanted to know how to go about implementing semaphores, locks and condition variables in C/C++. I am learning OS concepts but want to get around implementing the concepts in C. Any tutorials? ...

C/C++ goto

Hi everybody! I want to declare an array of "jumplabels". Then I want to jump to a "jumplabel" in this array. But I have not any idea how to do this. It should look like the following code: function() { "gotolabel" s[3]; s[0] = s0; s[1] = s1; s[2] = s2; s0: .... goto s[v]; s1: .... goto s[v]; ...

sample rc file for splint

I am using splint for code checking, and it is throwing out a huge number of warnings. Some of them, I guess can be ignored. I am in the process of creating the .splintrc by trial and error. My question, Is there some sample .splintrc file that can be used? I am using splint for C code, written for a multi-tasking embedded system. ...

Linux API to list running processes?

I need a C/C++ API that allows me to list the running processes on a Linux system, and list the files each process has open. I do not want to end up reading the /proc/ file system directly. Can anyone think of a way to do this? ...