c

Image scaling and rotating in C/C++

What is the best way to scale a 2D image array? For instance, suppose I have an image of 1024 x 2048 bytes, with each byte being a pixel. Each pixel is a grayscale level from 0 to 255. I would like to be able to scale this image by an arbitrary factor and get a new image. So, if I scale the image by a factor of 0.68, I should get a new i...

How to disable interface keyword on visual C++ Express 2008?

I am compiling a legacy C code here and there is a lot of variables and struct members named "interface", but VC2008 express is complaining about these, do you know how to disable this? I already changed settings to compile the code only as a C code, but no effect on this. ...

Virtual area to pages

In the Linux kernel, given the task_struct's mm I can access the process's list of vm_area_structs. Given these vm_area_structs, how do I get the struct pages which actually correspond to this vma? I tried looking for functions in mm/memory.c and the like, but I was at a loss. Edit: the idea is to find which pages in the vma are curre...

embedded sql in C

I've been attempting to write embedded SQL statements for DB2 that ultimately gets compiled in C. I couldn't find a tutorial or manual on the embedded SQL syntax for C for reference. One case I would like to do is to insert data into a table. I know most embedded sql statements need the initalizer EXEC SQL, but thats the extent of my k...

How can I determine if a Win32 thread has terminated?

How can I determine if a Win32 thread has terminated? The documentation for GetExitCodeThread warns to not to use it for this reason since the error code STILL_ACTIVE can be returned for other reasons. Thanks for the help! :) ...

Microsoft word Text Parser in "C"

Hi, I would like to know the procedure to adopt to parse and obtain text content from Microsoft word (.doc and .docx) documents . programming language used should be plain "C" (should be gcc). Are there any libraries that already do this job, extension : can i use the same procedure to parse text from Microsoft power point files also ...

paste on site, syntax highlighting.

I am getting a web host and i have projects with teammats. I thought it be a nice idea to have my own paste site that has no expiry date on paste (i know http://pastie.org/ exist) and other things. i wanted to know. Whats a simple highlight lib i can use on code? i would be only using C/C++. ...

How do you return a variable in a C -> ruby interface?

A follow up to an earlier question, showing the part that fails when I try to get the error message from my target library: require 'gt4r' @@test_environment = "INCLUDE=C:\\graphtalk\\env\\aiadev\\config\\aiadev.ini" @@normal_user = "BMCHARGUE" describe Gt4r do it 'initializes' do rv = Gt4r.gTD_initialize @@normal_user, @@norm...

How do I tell valgrind to memcheck forked processes?

I have a process x that I want to check for leaks with valgrind. The problem is that x is run by y, and y in turn is run by z. I can't run x standalone because y and z setup the environment for x, such as environment variables, command line switches, files needed by x etc. Is there any way I can tell valgrind to run on z but to fol...

nested preprocessor macro

I would like to do the equivalent of the following: #define print_max(TYPE) \ # ifdef TYPE##_MAX \ printf("%lld\n", TYPE##_MAX); \ # endif print_max(INT); Now the #ifdef or any nested preprocessor directive is not allowed as far as I can see in a function macro. Any ideas? Update: So it seems like this is not possible. Even a...

UnitTest how do you organise your testing files?

Currently, I am splitting all my tests by package (projects). So if I have 12 projects, I will create 1 more project for Unit Test with 12 classes that will test all my package. Do you do the same way or do you have 1 testing class by class? How do you organize all your test? ...

What technology to get NTFS access rights in C ?

Hello everybody, I am thinking hard about how to play with access rights on several platforms. Now I am reaching Microsoft Windows and permissions on NTFS files/directories. I must say that I am working in C language. My question is pretty general. I have a username and a file path. Do I need more information to check if the user has ...

CRC32 C or C++ implementation

I'm looking for an implementation of CRC32 in C or C++ that is explicitly licensed as being free or public domain. The implementation here seems nice, but the only thing it says about the license is "source code", which isn't good enough. I'd prefer non LGPL so I don't have to fool around with a DLL (my app is closed source). I saw th...

how to use libxml2 to modify an existing xml file?

I need to take an existing xml file, and modify just a few attributes and write the file back out. I was thinking of using libxml2 to get this done. Application is C/C++ running on Linux. Thing is, libxml2 seems to include several variations of the kitchen sink, along with portable washrooms, showers, and various other things connecte...

Is C code still considered C++?

The comment to this answer got me wondering. I've always thought that C was a proper subset of C++, that is, any valid C code is valid C++ code by extension. Am I wrong about that? Is it possible to write a valid C program that is not valid C++ code? EDIT: This is really similar to, but not an exact duplicate of this question. ...

Is there an optimal byte size for sending data over a network?

I assume 100 bytes is too small and can slow down larger file transfers with all of the writes, but something like 1MB seems like it may be too much. Does anyone have any suggestions for an optimal chunk of bytes per write for sending data over a network? To elaborate a bit more, I'm implementing something that sends data over a networ...

How do I create a sqllite3 in-memory database?

One of the appropriate uses for sqlite3 is "in-memory databases". This sounds like a really useful tool for my C++ applications. Does anyone have an example of how this is done in C or C++? I'm specifically looking for a canonical way to slurp several flat-files into an in-memory database, then do some joins. ...

Does anyone know of a C/C++ Unix QR-Code library?

I'm looking for a QR-Code library for C/C++, not Java or .Net please. Anyone knows of one? Note: There was a similar question a while back however but it didn't get answered properly. ...

How to estimate the thread context switching overhead?

I am trying to improve the performance of the threaded application with real-time deadlines. It is running on Windows Mobile and written in C / C++. I have a suspicion that high frequency of thread switching might be causing tangible overhead, but can neither prove it or disprove it. As everybody knows, lack of proof is not a proof of op...

Difference between using fork/execvp and system call

Hi What is the difference between using system() to execute a binary and using the combination of fork/execvp. Is there any security/portablility/performance difference. ...