c

Non-threadsafe file I/O in C/C++

While troubleshooting some performance problems in our apps, I found out that C's stdio.h functions (and, at least for our vendor, C++'s fstream classes) are threadsafe. As a result, every time I do something as simple as fgetc, the RTL has to acquire a lock, read a byte, and release the lock. This is not good for performance. What's ...

C Pointer Question

In my embedded c program I have a struct: struct var{ unsigned long value; unsigned long length; + More } An array of these structs is used to hold variables. Most of the variables stored are simply stored in 'value' and so the length is set to 1. However, some of these variables are arrays and Im trying to store the star...

c free question

Is this okay to do in c? int *i; // do stuff i = NULL; i = (int *) some_func(); // do stuff if (i != NULL) free(i); i = NULL; // do stuff i = (int *) some_func(); // do stuff if (i != NULL) free(i); i = NULL; ...

C: How to correctly declare an array of strings?

I saw both : const char* arr = {"foo", "bar"}; and const char* arr[] = {"foo", "bar"}; What is the correct and generally standard way? What is the difference between two? what is the difference between const char**arr = {"foo", "bar"}; and const char* arr[] = {"foo", "bar"}; and const char* * const ar...

Sharing memory between two processes (C, Windows)

Since I haven't found an answer to the question asked previously here I'm trying a different approach. Is there any way to share memory between two processes? The second process gets the information from an injection since it's a legacy program that it's not being supported anymore. My idea is to inject some code there, in the struc...

fast algorithm for drawing filled circles?

I am using Bresenham's circle algorithm for fast circle drawing. However, I also want to (at the request of the user) draw a filled circle. Is there a fast and efficient way of doing this? Something along the same lines of Bresenham? The language I am using is C. ...

What is the difference between memmove and memcpy?

What is the difference between memmove and memcpy? Which one do you usually use and how? ...

Object Oriented pattern in C ?

Possible Duplicate: Can you write object oriented code in C? I am writing a large application in C and have heard that prior to the advent of C++ programmers used to implement the "Object Oriented" pattern in C. My question is what is the usual form this pattern takes? and how would I go about implementing such an OOP pattern in...

Dots in Variables? VC9 gives parsing errors when building beecrypt

Hi, I want to compile the beecrypt library under VS2008. But several of the below structures produce a syntax error (C2059 syntax error: '.'): const hashFunction md5 = { .name = "MD5", .paramsize = sizeof(md5Param), .blocksize = 64, .digestsize = 16, .reset = (hashFunctionReset) md5Reset, .update = (hashFunctionUpdate) md5Update, .diges...

"C subset of C++" -> Where not ? examples ?

I read in a lot of books the claim that "C is a subset of C++". Actually some (good?) books say: "C is a subset of C++ except the little Details". I am interested what these details are. I've never seen one. ...

When doing a parallel search, when will memory bandwidth become the limiting factor?

I have some large files (from several gigabytes to hundreds of gigabytes) that I'm searching and trying to find every occurrence of a given string. I've been looking into making this operate in parallel and have some questions. How should I be doing this? I can't copy the entire file into memory since its too big. Will multiple FILE* ...

Reference for Net-SNMP API?

I'm currently developing a monitoring application for some in-house hardware using net-snmp. I have code that somewhat works, when calling snmp_pdu_free() my code segfaults. I am creating the pdu struct with snmp_create_pdu(). I would like an API reference to see if I am in fact writing my code correctly, but I haven't been able to find ...

Why doesn't __attribute__((constructor)) work in a static library?

In the following example, the program should print "foo called": // foo.c #include <stdio.h> __attribute__((constructor)) void foo() { printf("foo called\n"); } // main.c int main() { return 0; } If the program is compiled like this, it works: gcc -o test main.c foo.c However, if foo.c is compiled into a static library, t...

Check for environment variable in another process?

In Windows, is there a way to check for the existence of an environment variable for another process? Just need to check existence, not necessarily get value. I need to do this from code. ...

In C, how do I get a specific range of numbers from rand()?

srand(time(null)); printf("%d", rand()); Gives a high-range random number (0-32000ish), but I only need about 0-63 or 0-127, though I'm not sure how to go about it. Any help? ...

Which database engine does Knowledge Flow's Obtain 24/7 product use?

I have been given the unenviable task of cleaning up after a developer who up and disappeared after failing to deliver on a project involving integrating Knowledge Flow's Obtain 24/7 with my client's back office systems. My client own's the source code to the Obtain 24/7 product and has had it extended by some of Obtain 24/7's origina...

Read data from serial port

How do i read data from serial port using C ? and then again transfer the data to modem ? I am using RS 232 cable for serial communication ... ...

How to write an application for the system tray in Linux

How do I write my application so it'll live in the system tray on Linux? In fact, just like CheckGmail. As with CheckGmail, I'd also like some sort of popup box to appear when I hover the tray icon. Is there an API, class or something for doing this? All I'm able to find seems to be for Windows. If I have to be language specific, then...

how can I save struct in file .... C lang

I'd like to save a struct in a file. I'd like to realize a function which makes this work. I tried this code but it didn't work. struct utilisateur // enregestrement pour sauvegarder les details de l utilisateur { char nom[20]; char prenom[20]; int place; char depart[20]; char arrive[20]; char sexe; int nwagon; }; struct uti...

Why does this C fuction not return an integer value?

When I try to execute my program, I get an error. I can't read the last value in "ch": int choi(char *Tvide[48])//permet de choisir la place selon les choix de l utilisateur { char fum, classe, pos; printf("\n S.V.P choisissez votre Classe (A:1 ere classe )/(B: 2 eme classe): "); classe = getche(); printf("\n Est ce q...