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 ...
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...
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;
...
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...
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...
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? Which one do you usually use and how?
...
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...
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...
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.
...
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* ...
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 ...
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...
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.
...
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?
...
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...
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 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...
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...
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...