c

Imagettftext like C function

I need to implement a functionality similar to PHP's imagettftext function. I need to enter a text and output a bmp image based on that. I already looked at freetype but it converts character by character and is not suitable to convert the whole text to an image. I am stuck at the moment. How can I access the source code of imagettftext ...

Build an application with some kernel memory disclosure

Hi all, I'd like to build a C application that I can then exploit to get some confidential information from the kernel memory. The issue is that I don't really understand where to start... I've found that the use of copy_to_user() without appropriate checks on the return value could lead to this sort of issue, but I don't understand ho...

Specific functions vs many Arguments vs context dependent

An Example Suppose we have a text to write and could be converted to "uppercase or lowercase", and can be printed "at left, center or right". Specific case implementation (too many functions) writeInUpperCaseAndCentered(char *str){//..} writeInLowerCaseAndCentered(char *str){//..} writeInUpperCaseAndLeft(char *str){//..} and so on... ...

Why do we need header files?

Possible Duplicate: In C++ why have header files and cpp files? Why do you need to include .h-files and not just the .c-files? Is this better in C++ or C#? ...

Python threads in embedded Python: How?

While experimenting with Python's (python.org) C API, I found myself wondering how to properly spawn threads via Python's threading package when Python itself is embedded in a C program. Functions PyEval_EvalCode and kin appear to terminate threads it "owns" as soon as the C function finishes evaluating a block of Python code. Roughly, r...

Why symbols of a shared library are not resolved at link time?

Hi all, This is my 2nd post on this site in my effort to understand the compilation/linking process with gcc. When I try to make an executable, symbols need to be resolved at link time, but when I try to make a shared library, symbols are not resolved at link time of this library. They will perhaps be resolved when I am trying to make a...

Determine if a piece of code exits the program with MSVC

On a Gnu system, I can write a C macro like dies_ok() that will fork a new process, run a piece of code, after which it can write to a shared piece of memory that it didn't exit, then in the parent process I can determine if it exited or not. This is useful for tests: dies_ok({int x = 0/0;}, "can't divide by zero"); lives_ok({int x = 3/...

Need help with logic (C)

I need to swap first n elements from two non repeating sequences(arrays), where n is a random integer. Seq1: 1 4 5 6 9 8 2 3 7 Seq2: 3 9 1 2 8 7 4 5 6 If n = 4 Seq1: 3 9 1 2 | 9 8 2 3 7 Seq2: 1 4 5 6 | 8 7 4 5 6 Now i need to repair the sequence by replacing the repeated numbers after '|'. How to do this? This is my effort.. for...

using rand to generate a random numbers

Hello, gcc 4.4.4 c89 I am using the code below. However, I keep getting the same number: size_t i = 0; for(i = 0; i < 3; i++) { /* Initialize random number */ srand((unsigned int)time(NULL)); /* Added random number (simulate seconds) */ add((rand() % 30) + 1); } I would like to get 0 to 3...

errors concatenating bytes from a block of bytes using memcpy

On occasion, the following code works, which probably means good concept, but poor execution. Since this crashes depending on where the bits fell, this means I am butchering a step along the way. I am interested in finding an elegant way to fill bufferdata with <=4096 bytes from buffer, but admittedly, this is not it. EDIT: the error ...

Heapsort in descending order not working

I have been looking at this for hours and can't figure this out. If the comparisons in the heapify function are changed to greater than, then the output is in increasing order as it should be. I want my list to be sorted in decreasing order though and it's not giving the correct output using the below code: #include <stdlib.h> #include ...

How to get pointers and sizes of variables from the compiler - from outside the compiled code?

I'd like the compiler to output a file containing the pointers to all global variables in the source code it is compiling, and also the sizes of them. Is this possible? Is there a way to do it in any c compiler? ...

ifort linker undefined reference

I'm compiling a large HPC system written in Fortran using the Intel compiler (ifort). There are about several hundred individual modules and they all compile fine, but the linker throws up this error: phys_grid.o(.text+0x91b2): In function `phys_grid_mp_assign_chunks_': : undefined reference to `_mm_idivrem_epi32' The _mm_idivrem_epi3...

Multiply defined linker error using inlined functions

The linker is reporting multiply defined errors for an inline function. I have the following code in a header file: struct Port_Pin { volatile uint32_t * port_addr_set_value; //!< Writing the pin value here sets the pin to high. volatile uint32_t * port_addr_clr_value; //!< Writing the pin value to this port clear...

Will GetPath() work for this?

I basically want to get the outline for a character. I was wondering how I could do this without drawing to the DC. Could I do something like this: (Psudocodeishly) BeginPath() TextOut("H") EndPath() GetPath() Will something like this work for GetPath? Will it return the glyph outline that I can then draw? Otherwise, how else could...

nested extern declaration warnings in c code

why do we get nested extern declaration warnings in c code . ...

ASCII char to int conversions in C

Possible Duplicate: Char to int conversion in C. I remember learning in a course a long time ago that converting from an ASCII char to an int by subtracting '0' is bad. For example: int converted; char ascii = '8'; converted = ascii - '0'; Why is this considered a bad practice? Is it because some systems don't use ASCII? ...

Runtime check failure #2 C/C++

Hi all, I have encountered a problem in my program that has me somewhat stumped. I had a program that was working fine (it was working fine on VS 2010 this is not an I upgraded to .NET and this error started happening post) with a program that is mostly c and some c++ (my boss HATES object oriented since it usually involves making calls ...

static and external variables

What are the diffrence between static and external variables.what are the advantages of making a static variable? why do we prefer making external variables in multifunction programs?the book says that else it gets ititialized very late .i dont get it . ...

how to move to location in graphics mode

What code do we use to move at a point on the screen in graphics mode(graphics.h)?As in normal we use goto(x,y). ...