c

Central Clickable MSDN like Linux System/C/C++ Standard Library Documentation

Hi all, If you are windows programmer and you want to program something new where you are going to use some new API with which you are not that familiar then you can type MSDN on your web browser and you get immediately what you need. Nicely grouped API functions where you can see what to include and what to link. I am looking for som...

Fast JPEG encoding library

Hi, anyone know of a free open-source jpeg encoding library for C/C++? Currently I'm using ImageMagick, which is easy to use, but it's pretty slow. I compared it to an evaluation of Intel Performance Primitives and the speed of IPP is insane. Unfortunately it also costs 200$, and I don't need 99% of the IPP). Also it will only work f...

Why is this C function crashing at fclose?

Hi guys! Please help me understand why this function throws an exception when it reaches fclose : void receive_file(int socket, char *save_to, int file_size) { FILE *handle = fopen(save_to,"wb"); if(handle != NULL) { int SIZE = 1024; char buffer[SIZE]; memset(buffer,0,SIZE); int read_so_far = 0; int re...

Failsafe conversion between different character encodings

Hello! I need to convert strings from one encoding (UTF-8) to another. The problem is that in the target encoding we do not have all characters from the source encoding and libc iconv(3) function fails in such situation. What I want is to be able to perform conversion but in output string have this problematic characters been replaced w...

Why is strncpy insecure?

I am looking to find out why strncpy is considered insecure. Does anybody have any sort of documentation on this or examples of an exploit using it? ...

Memcpy() in secure programming?

I recently stumbled across an article that claims Microsoft is banning the memcpy() function in its secure programming shops. I understand the vulnerabilities inherent in the function, but is it necessary to ban its use entirely? Should programs I write be avoiding memcpy() entirely, or just ensuring that it's used safely? What alternat...

in windows, how to have non-blocking stdin that is a redirected pipe?

I have a Windows C program that gets its data through a redirected stdin pipe, sort of like this: ./some-data-generator | ./myprogram The problem is that I need to be able to read from stdin in a non-blocking manner. The reason for this is that (1) the input is a data stream and there is no EOF and (2) the program needs to be able to...

comparing strings

considering this piece of code char *pass="test"; int keyPressed; char *password=(char *)malloc(PASS_LENGTH*sizeof(char)); int index=0; printf("Enter the password please\n"); do { keyPressed=getch(); password[index++]=keyPressed; } while(keyPressed!=13); int result=strcmp(pass,password);...

What preprocessor directive or other method should I use to discern 32- vs 64-bit environment?

I would like to compile the following C program for 32- and 64-bit systems. #include <stdio.h> #include <stdlib.h> ...

TestDriven.NET and native C Library

I am working on a C# application that makes calls to a native Windows C dll. We use TestDriven.NET with xUnit for testing. The problem is, whenever we run unit tests that use the C library (which we did not write), and then try to build afterwards, there is a build error about how the library is being used by another process. To fix i...

using spawnl and waiting for child process to exit

I am using c++ in borland development studio to launch a process. After the process is launched, the parent application is supposed to wait for it, but still keep processing windows messages. I tried using spawnl with P_WAIT after launching a timer, but timer wont fire when thread is blocked, i also tried using spawnl with P_NOWAIT toge...

Need help understanding a C function

Here's the deal: I'm trying, as a learning experience, to convert a C program to C++. This program takes a text file and applies modifications to it according to user-inputted rules. Specifically, it applies sounds changes to a set of words, using rules formatted like "s1/s2/env". s1 represents the characters to be changed, s2 represents...

Cross-Platform way to get CPU/Memory utilization

Looking for a library or a fairly cross platform method to get CPU utilization, memory utilization, etc in C/C++. Something OTHER than getrusage(), I need for entire system, not one process. I've checked around, but haven't found much. I really need it on Linux, Mac Os X, and Windows, but if there's a solution for *nix systems (includ...

concurrent variable access in c

I have a fairly specific question about concurrent programming in C. I have done a fair bit of research on this but have seen several conflicting answers, so I'm hoping for some clarification. I have a program that's something like the following (sorry for the longish code block): typedef struct { pthread_mutex_t mutex; /* some sh...

Auto complete Text Editor for C

First post here and a new to C and programming in general. I do have a little HTML and CSS experience but I am in the process of working my way through C for Dummies. I am trying to find a text editor that auto completes C code. Currently using SubEthaEdit which is the third text editor I have tried. How can I get it to auto complete? ...

How does system() exactly work in linux?

I've been reading its man page but haven't yet been successful in figuring out how it works. On calling system(), is a new child process forked and the shell binary exec()-ed in it? That may be a stupid guess though. ...

Objective advantages of C-style syntax

There is a really big number of programming-languages that are heavily influenced by C-style syntax (curly-braced, semicola, etc.), maybe more than by any other syntactial style. And till this day, many modern and successful or even newly invented languages use this syntax - just think of Java, C++, C#, PHP, JavaScript, C, Perl etc. Are...

is it worth it to compile a C program and run it instead of PHP page?

it seems that most of the time, the speed gained is not worth it -- is it so? otherwise many people will do it for their most popular page. Is there real benefit of using a C program. I can think of a case where it is not important: when the network bottleneck on the server is quite bigger than the CPU bottleneck, then how fast the pr...

Errors while compiling Neko VM OS X

I'm trying to compile the Neko VM on Mac OS X (10.5.7) using GCC 4.01 and I'm completely stuck, because it stops while compiling saying: vm/threads.c:202: error: conflicting types for 'neko_thread_register' vm/neko_vm.h:37: error: previous declaration of 'neko_thread_register' was here I've tried googling this and some say it's becaus...

Why are global variables bad, in a single threaded, non-os, embedded application

Most of the objections I see to using global variables make sense since they refer to issues of multiple threads, thread safety, etc. But in a small, single threaded, non-OS, case, what objections do you have? In my case, I'm writing my embedded system in "C", if it matters. I'm also the only developer on the product. Why would elimin...