c

What are these values representative of in C bitwise operations?

Hi All, I'm trying to reverse the order of bits in C (homework question, subject: bitwise operators). I found this solution, but I'm a little confused by the hex values (?) used -- 0x01 and 0x80. unsigned char reverse(unsigned char c) { int shift; unsigned char result = 0; for (shift = 0; shift < CHAR_BITS; shift++) ...

Naming convention in Objective C /C , start with "_"?

Something I see ppl define the variable like this: b2World *_world; b2Body *_body; CCSprite *_ball; instead of b2World *world; b2Body *body; CCSprite *ball; I familiar with the second one, but not the first one. So, I checked the Wikipedia about naming convention: Names beginning with double underscore or an underscore and a...

Declaring pointers; asterisk on the left or right of the space between the type and name?

Possible Duplicates: What makes more sense - char* string or char *string? Whats your preferred pointer declaration style, and why? I've seen mixed versions of this in a lot of code. (This applies to C and C++, by the way.) People seem to declare pointers in one of two ways, and I have no idea which one is correct, of if it ...

Issue with dynamic array Queue data structure with void pointer

Hi, Maybe there's no way to solve this the way I'd like it but I don't know everything so I better ask... I've implemented a simple Queue with a dynamic array so the user can initialize with whatever number of items it wants. I'm also trying to use a void pointer as to allow any data type, but that's the problem. Here's my code: type...

Question about C Pointers (just learning)

I am curious as to why this is an error and what the error message means. Here is some code: int *x[] = {"foo", "bar", "baz"}; int *y[] = {"foo", "bar", "baz"}; x = y; I try to compile and I get this: error: incompatible types when assigning to type ‘char *[3]’ from type ‘char **’ Question #1 why is this an error? and Question #2 ...

communication between 2 programs written in different language - Serialization ?

when is serialization,marshaling etc required during communication between programs residing across 2 different machines /network/Internet? Suppose I have a client program in java/flash and a server program in C. Can't I implement communication using a custom protocol of my own ? I guess so. When is serialization etc needed?I am aware J...

Implementing the modulo operator as a function in C

How can we implement the modulo operator as a function in C without using the operator? ...

Espeak SAPI/dll usage on Windows ?

Question: I am trying to use the espeak text-to-speech engine. So for I got it working wounderfully on linux (code below). Now I wanted to port this basic program to windows, too, but it's nearly impossible... Part of the problem is that the windows dll only allows for AUDIO_OUTPUT_SYNCHRONOUS, which means it requires a callback, but I ...

Doing 64 bit manipulation using 32 bit data in Fixed point arithmetic using C.

Hi, I am stuck with a problem. I am working on a hardware which only does support 32 bit operations. sizeof(int64_t) is 4. Sizeof(int) is 4. and I am porting an application which assumes size of int64_t to be 8 bytes. The problem is it has this macro BIG_MULL(a,b) ( (int64_t)(a) * (int64_t)(b) >> 23) The result is always...

storage classes

What is the difference between a variable declared as an auto and static? What is the difference in allocation of memory in auto and static variable? Why do we use static with array of pointers and what is its significance? ...

Picking good first estimates for Goldschmidt division

I'm calculating fixedpoint reciprocals in Q22.10 with Goldschmidt division for use in my software rasterizer on ARM. This is done by just setting the numerator to 1, i.e the numerator becomes the scalar on the first iteration. To be honest, I'm kind of following the wikipedia algorithm blindly here. The article says that if the denomina...

Non-member functions in Objective-C

I want to write a standalone function in Objective-C; so essentially a C-style function, with Objective-C calls in it. For example: NSString* someFunc() { NSString* str = [[NSString alloc] init]; return str; } I declare the function in a header file, and define in it a .m file. However, the function doesn't appear to be compiled in...

Most optimized way to calculate modulus in C

I have minimize cost of calculating modulus in C. say I have a number x and n is the number which will divide x when n == 65536 (which happens to be 2^16): mod = x % n (11 assembly instructions as produced by GCC) or mod = x & 0xffff which is equal to mod = x & 65535 (4 assembly instructions) so, GCC doesn't optimize it to this ...

1k of Program Space, 64 bytes of RAM. Is 1 wire communication possible?

(If your lazy see bottom for TL;DR) Hello, I am planning to build a new (prototype) project dealing with physical computing. Basically, I have wires. These wires all need to have their voltage read at the same time. More than a few hundred microseconds difference between the readings of each wire will completely screw it up. The Arduino...

c - convert a mixed-case string to all lower case

is the best/cleanest way to just do a for loop iterating through each position and call tolower() on it? ...

c - why does it make sense that indexing a character pointer is an int?

char *a = "apple"; printf("%s\n", a); // fine printf("%s\n", a[1]); // compiler complains an int is being passed Why does indexing a string pointer give me an int? I was expecting it to just print the string starting at position one (which is actually what happens when i use &a[1] instead). why do i need to get the address? ...

What's the output object file format of GNU assembler as?

I have checked the assembler options of GNU assembler as and I didn't find an option to specify the output object file format. If I am using the following command as -o foobar.o foobar.s What object file format will I get? The as manual says that "The GNU as can be configured to produce several alternative object file formats." But h...

Treat a void function as a value

I'm writing some terrible, terrible code, and I need a way to put a free() in the middle of a statement. The actual code is: int main(){ return printf("%s", isPalindrome(fgets(malloc(1000), 1000, stdin))?"Yes!\n":"No!\n") >= 0; // leak 1000 bytes of memory } I was using alloca(), but I can't be sure that will actually work on ...

Parsing a file in C

I need parse through a file and do some processing into it. The file is a text file and the data is a variable length data of the form "PP1004181350D001002003..........". So there will be timestamps if there is PP so 1004181350 is 2010-04-18 13:50. The ones where there are D are the data points that are three separate data each three dig...

what should the output of a lexer be in c?

#include<stdio.h> int main() { int a,b; a=a+b; printf("%d",a); return 0; } what should be the output if this code is passed through a lexer ...