c

I want to make apps for Android what other language(s) can i make them in EXCEPT java?

Possible Duplicate: Alternatives to Java for Android development? I want to make apps for Android (Mobile OS) what other language(s) can i make them in EXCEPT java? Thank you in advance ;-) ...

best practice for delivering a C API hiding internal functions

Hi all, I have written a C library which consists in a few .h files and .c files. I compile it as a .a static library. I would like to expose only certain functions to the user and keep the rest as "obscure" as possible to make reverse engineering reasonably difficult. Ideally my library would consist of: 1- one .h file with only th...

Is there any way to improve this function which replaces occurrences of substrings with another string in an malloc allocated string?

Hello. I'm very new to C and I decided to make a function called str_replace which replaces strings inside strings which have been made using malloc. It appears to work but can anyone find any room for improvements. Any advice will be appreciated. I'd like to know if people think finding the number of occurrences to calculate the new s...

Using c99 in C++'s `extern "C"` blocks

I would like to have a function written in C, but callable from C++ which takes a restricted pointer. This is only available in c99, so g++ doesn't like it, even in extern "C" blocks. How can I get around this limitation? ...

Where do I define my const array in C?

I'm writing some C and I have a lookup table of ints. I'm a little rusty... where do I declare and initialize the array so that I can use it in multiple C files? Can I declare it in an H file and initialize it in a C file? ...

Wrapping a number?

I have this float which is a rotation angle. Camera.roty += (float) diffx * 0.2; where diff is the change in mouse position. In OpenGL it will wrap it if it exceeds 360 or is below 0, but how could I do this if I want to verify if the angle is between 0 and 180? Thanks ...

C segmentation faults due to fopen(). How to trace and what to look for?

Hi, (this was asked on ffmpeg-devel list, but counted way offtopic, so posting it here). ffmpeg.c loads multiple .c's, that are using log.c's av_log -> av_log_default_callback function, that uses fputs; void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) { ... snprintf(line, sizeof(line), "[%s @ %p] ", (*par...

How to define and declare global variables for use by library code?

main file (prog.c): #include "log.c" #include "library.c" static char * Foo; If some variable (char * Foo) is defined in main file (prog.c), and it is required by log.c function called from library.c, how to correctly declare Foo to be visible from log.c's namespace? ...

c handle large file

I need to parse a file that could be many gbs in size. I would like to do this in C. Can anyone suggest any methods to accomplish this? The file that I need to open and parse is a hard drive dump that I get from my mac's hard drive. However, I plan on running my program inside of 64-bit Ubuntu 10.04. Also given the large file size, the ...

Designing parameters and return values of functions for a tasklist program

I'm working on a tasklist program to brush up on my C before I take a class. I have two structs, task and tasklist. Here is the task struct: typedef struct task { char name[100]; bool completed; /* bool is described as an enum in an included header file */ date due_date; /* date is a described as a struct in an included header f...

How can I run a specific function of thread asynchronously in c/c++?

Performance tuning: writing data to multiple pipes Now I'm doing it in a single thread: for(unsigned int i = 0; i < myvector.size();) { tmp_pipe = myvector[i]; fSuccess = WriteFile( tmp_pipe, &Time, sizeof(double), &dwWritten, NULL ); if(!fSuccess) { myvector.erase(myvector.begin()+i); printf("Client pip...

How to check whether there's enough space before WriteFile in c in windows?

hPipe = CreateNamedPipe( lpszPipename, // pipe name PIPE_ACCESS_DUPLEX, // read/write access PIPE_TYPE_MESSAGE | // message type pipe PIPE_READMODE_MESSAGE | // message-read mode PIPE_WAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // max. instances 10...

Z ordering geometry

I'm making a game that is entirely made of cubes. I notice that when I walk forward it runs lightening fast, but if I rotate the player in the opposite direction, its cripplingly slow. So what I did is ordered based on angle, but I still get some angles that are a bit slow. Here is how I did it: I basically reverse iterate in certain an...

Avoiding glBindTexture() calls?

My game renders lots of cubes which randomly have 1 of 12 textures. I already Z order the geometry so therefore I cant just render all the cubes with texture1 then 2 then 3 etc... because that would defeat z ordering. I already keep track of the previous texture and in they are == then I do not call glbindtexture, but its still way too m...

Multiple preincrement operations on a variable in C++(C ?)

Why does the following compile in C++? int phew = 53; ++++++++++phew ; The same code fails in C, why? ...

Do POSIX lfind()/lsearch() perform better than looping manually?

Do lfind/lsearch perform better than a typical looping solution that checks each item until it matches? Is there any special sauce/reason that these functions exist? ...

Fetching reference to superview from UITextField ?

Hi all, I have created three UIImageViews. I then added a UITextField to each image as a subview. When the user clicks on the text field I want to capture which UIImageView ths text field belongs to. I am trying the following code : -(void)textFieldDidBeginEditing : (UITextField *)textField { textField = retainedObject; MyPicture *...

Terminate string full of garbage ?

Does C allow to place a string terminator at the end of read bytes full of garbage or is it only guaranteed if the read bytes are chars ? I need to read something like this from stdin but I do not know how many chars to read and EOF is not guaranteed: Hello World!---full of garbage until 100th byte--- char *var = malloc(100 + 1); ...

Is this right approach to write the code of strstr through pointers in c??

char* fstrstr(char *s1,char *s2) { int i=0,flag=0; char *s4,*s3; // s4 for retaining the value of s2 s4 = s2; while(*s1 != '\0' && *s2 != '\0') { if(*s1 == *s2) { *(s3+i) = *s1; s2++; s1++; i++; flag = 1; } else { ...

A container for accessing contents by 2d/3d coordinates

There are a lot of games that can generally be viewed as a bunch of objects spread out through space, and a very common operation is to pick all objects in a sub-area. The typical example would be a game with tons of units across a large map, and an explosion that affects units in a certain radius. This requires picking every unit in the...