c

Inline Assembly: Passing pointers to a function and using it in that function in assembly

Guys, I'm using ARM/Cortex-A8 processor platform. I have a simple function where I have to pass two pointers to a function. These pointers are later used in that function which has only my inline assembly code This plan is only to achieve performance. function(unsigned char *input, unsigned char *output) { // What are the assembl...

What to choose as a good marker in C?

Hello guys, So, I'm wondering if there's a good marker to choose in C, apart from the common 0xDEADBEEFor the less appealing (for proper code) 0x0BADA550. What's your favorite? Is there any reason to choose one particular value or another? ...

A tool to convert JSON to C struct?

I'm just wondering if anyone has already created a tool that will take a given JSON string and write the code for an identical struct in C along with the parser code specific to that struct. I'm about to do this myself using JSON-C, but I thought I'd ask first. ...

Integer overflow in C: standards and compilers

Edited to include proper standard reference thanks to Carl Norum. The C standard states If an exceptional condition occurs during the evaluation of an expression (that is, if the result is not mathematically defined or not in the range of representable values for its type), the behavior is undefined. Are there compiler switches th...

How do I disable tailcall optimizations in gcc

Hi all, Wondering if anyone knows the flag for gcc to disable tailcall optimizations. Basically in a tailcall optimization, gcc will replace a stack frame when the return value from a called function is passed through (via return) or nothing else happens in the function. That is, in void main() { foo(); } void foo() { ...

Execution at main method

Hii , We generally see that the program execution begins in the main method for the languages like C , C++ , Java (i am familiar with these). I want to know how the compiler knows the presence of MAIN method in the program . What does the main method signify besides that it is the entry point for program execution ...How does these cr...

How to use the cl command?

Hi, all, I found a piece of information on how to call c files in python, in these examples: there is a c file, which includes many other header files, the very beginning of this c files is #include Python.h, then I found that #include Python.h actually involves many many other header files, such as pystate.h, object.h, etc, so I incl...

Reading StdOut Asynch from a c console app

I have a console based c app . I am executing it from c# silently using Redirecting Standard Output and doing it synchronously which works fine. Now i want to do it in asynch manner which is giving output like synch manner. i.e OutPutDataRecieved event is fired but only after the console app(exe) finishes.OutputDataRecieved event is fire...

getopt - parameters that aren't flags?

I'm trying to use the getopt function for the first time only I'm having problems with arguments that aren't flags. For instance, in my code when a unknown argument is given I want to use it as a input file. When I run this with only a file name it is not printed, if I first use a flag, any flag, then I can print it. How can I fix this?...

How to read and extract information from a file that is being continuously updated?

This is how I am planning to build my utilities for a project : logdump dumps log results to file log. The results are appended to the existing results if the file is already there (like if a new file is created every month, the results are appended to the same file for that month). extract reads the log result file to extract relevant...

C approximation functions

I am making some approximation functions for exp, log, and sqrt in C for java. I'm a little rusty on how pointers work -- is this grammar correct? #include <math.h> #include "QDMath.h" JNIEXPORT jdouble JNICALL Java_QDMath_exp (JNIEnv *env, jclass class, jdouble val) { jint tmp = (jint) (1512775 * val + 1072632447); jdouble ...

Can I read a specific image row using libjpeg?

Using libjpeg, if possible, I would like to read a row from the middle of a JPEG image without reading all the preceding rows. Can this be done? ...

strstr through pointers in c language

is this the standard code for strstr i made???? char* fstrset(char *s,char *t) { int b, i=0,j=0; while(*(s+i)!='\0') { if(*(t+j)=='\0') break; else if(*(s+i)==*(t+j)) { i++;j++;b=1; } else { i++;b=0;j=0; } } if(b==0) return((char*)NULL); else if(b==1) return(s+i-j); } ...

Beginner C programming help

Ok, to start off, I am taking a C programming class this semester, and somehow was allowed to register even though I have not taken the prerequisite course. I thought I would still be able to handle it, but now that I have passed the point of no return for dropping it, I have found myself completely lost. For my present assignment I am...

problem writing bitmap file header in C

Hi, I am trying to create a new bitmap file using C. This is a struct for the .bmp file header. #define uint16 unsigned short #define uint32 unsigned long #define uint8 unsigned char typedef struct { uint16 magic; //specifies the file type "BM" 0x424d uint32 bfSize; //specifies the size in bytes of the bitmap file uint16 bfReserv...

How do I avoid both global variables and magic numbers?

I know and understand that global variables and magic numbers are things to avoid when programming, particularly as the amount of code in your project grows. I however can't think of a good way to go about avoiding both. Say I have a pre-determined variable representing the screen width, and the value is needed in multiple files. I coul...

problem linking my C++ class to my C static library .a on iphone xcode

Hi all, I have a problem linking with a .a C static library I have compiled as a separate target. My library is called libtest.a and has only one function: int test() which returns 1 always. I have put libtest.a and test.h (its header file) in a mylibrary_directory Then I create a new iphone view base project and added mylibrary_dir...

getpeername() Returns Wrong Data

I am writing my first sockets program on Linux and am trying to print the IP address and port of the peer I have connected to. I use getpeername() along with inet_ntop() and ntohs() to get the data out of the sockaddr_in struct. When I look at the results, I get an IP address that does not go to any server that I know of (ping fails) a...

Question regarding interrupt handler

Can I do floating point operations in interrupt handler ? (x86 or 64) Also I would like know can I use print function inside the interrupt handler ? ...

toggle a bit at ith positon

Possible Duplicate: How do you set, clear and toggle a single bit in C? Can some one help me how to toggle a bit at ith position. One way is to ((n>>i)^1) < < i. Are there any other ways ? ...