c

How to know the bytes amount used by a pointer?

Hi, I have a pointer (uint8_t *myPointer), that I pass as paramether to a method, and then this method set the value to this pointer, but I want to know how much bytes are used (pointed ?) by the myPointer variable. Thanks in advance and excuse me by my english. ...

automatic casting (or not?) in c

I'm trying to learn C from a Ruby/PHP/Java background, and I've found that you almost always explicitly cast things (at least in tutorials). Like, I always see things like double x, y; x = 1.0; /*...*/ y = x*5.0; However, it seems that on my Mac's version of GCC, automatic casting works. Is leaving the .0 on things just a matter of ...

Calling a Lua script from C: errors

I'm new at Lua and writing bindings in general. At the moment I'm just trying to compile the first example found here (with the functions updated to Lua 5.1). #include <stdio.h> #include "lua.h" #include "lualib.h" #include "lauxlib.h" /* the Lua interpreter */ lua_State* L; int main ( int argc, char *argv[] ) { /* initialize Lua...

Assigning and incrementing the same variable in a single expression

Possible Duplicate: Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc) Is i=i++ valid? Why or why not? ...

How to go about adding unit tests to an established (autotools) C project

I have a fork of openssh with some new features and want to write some unit tests to make sure they work at build. Grafting Check into openssh's autotools configuration is diffacult (because I don't really understand autotools) Is there an easier to use C unit test framework? One less closely tied to autotools? How about a better way o...

Good C library to parse apache log file

I would like to parse a lot of apache log files with a C library. Who knows a good C library which is optimized for good performance? Thank you for advice! ...

Converting mouse position to world position OpenGL

Hey, I'm working on a map editor for my game, and I'm trying to convert the mouse position to a position in the game world, the view is set up using gluPerspective ...

"Selected" style for WinAPI toolbar button?

Is there a way to make a toolbar button look different than the rest (Aside from changing bitmap or setting its state to Disable? Is there away to make it look highlighted all the time? I want the selected tool to look selected. Thanks (Sort of like the way open applications are "Selected" in Windows 7. ...

computing Pythagorean triplets with c

I'm trying to solve Project Euler #9, which is http://projecteuler.net/index.php?section=problems&amp;id=9. I've looked through this code, and the logic seems right…but I'm not getting any output at all, not even the printfs in the loop. I'm (obviously) a C newbie, trying to learn from higher level languages…could you tell me what's goi...

What language is this program written in?

This looks like code in the C language, but I am not completely sure ... # define v putchar # define print(x) main(){v(4+v(v(52)-4));return 0;}/* #>+++++++4+[>++++++<-]>++++.----.++++.*/ print(202*2);exit(); #define/*>.@*/exit() ...

Declaring a 2-dimensional array of unknown size, C

I have an array declared as a member of a struct in C. The array is declared as: char mValue[MAXROWS][MAXCOLUMNS]; where MAXROWS and MAXROWS are 300. Is there a better way to do this? I mean, should I declare these as pointers instead? Thanks! ...

C Preprocessor and if-else condition statement question

I run my C code in vs2010 (win32 console application). It was compiled as c++ application. #include "stdafx.h" #define YES 1; #define NO 0; // function to determine if an integer is even int isEven(int number) { int answer; if ( number % 2 == 0) answer = YES; else answer = NO; retu...

How can I create a parallel stack and run a coroutine on it?

Hey guys, In today's "Zneak's time-wasting adventures", I decided I should try to implement coroutines (I think that's how I should call them). I expect to have to use assembler, and probably some C if I want to make this actually useful for anything. Bear in mind that this is for educational purposes. Using an already built coroutine ...

How to define a constant conditionally

Hi All, I want to define some constants in my C file. Its assembly code like this: Const1 = 0 Const2 = 0 IF Condition1_SUPPORT Const1 = Const1 or (1 shl 6) Const2 = Const2 or (1 shl 3) ENDIF IF Condition2_SUPPORT Const1 = Const1 or (1 shl 5) Const2 = Const2 or (1 shl 2) ENDIF Could you tell me the simplest w...

Need some help with serialization

I am trying to write a program to serialize a linked list to a file without using any libraries. My problem is how to add or remove nodes to the serialized structure since I dont have next pointer ? Also how can I avoid fragmentation ? Thanks & Regards ...

In C, does an array of a structure gets allocated in the stack?

I think this maybe a really dumb question, but i just want to be clarified. Thanks in advance! I'm not sure if an array of structure declared as a local variable inside a function gets allocated in the stack. Doesn't? ...

[c] Array index efficiency (specifically, temporary vars)

I've read a fair amount of stuff about efficiency of array indices vs. pointers, and how it doesn't really matter unless you're doing something a lot. However, I am doing this a lot. The code in question has an array of structs. (Two different ones, for two different types actually, but whatever). Since my background is mostly in hig...

Remove Blank spaces in a string in O(n).

How to remove blank spaces in a string with a complexity of O(n). My approach is using two indexes. One will traverse till length on string. Other will be incremented only when a non-blank character is encountered. But i am not sure of this approach. TIA, Praveen ...

What are the exact contents of a program stack in C?

I want to know the exact contents of a program stack. How is the branching operation done? What is meant by memory dump while debugging a program using gdb? Does it give the program stack? TIA, Praveen ...

Resources on Writing Compiler Backends for OO Languages ?

Greetings Overflowers, I am trying to deeply understand how one can develop an x86 (ia32/ia64) backend for OO languages (staticly/dynamically tryped), mainly to be run on Windows OS. I have a good understanding of the x86 architecture, Windows architecture and how to get a code to the tree level ready to be optimized and serialized int...