c

Writing an API to communicate with a device connected on Serial port

I am afraid that several terminologies in my question are wrong. Please bear with me and correct me wherever I am wrong. I have to write a library/program that will provide set of function to operate a card reader attached at Serial Port. Like to eject card that was inserted in it, user will simply have to call in his code, for example,...

How to read symbols of an object file using C

Hi guys, Question is simple, i have a object file and i want to read the symbols of the object file via code. I am aware that the linux command "nm" would be able to do this, but i want to be able to do it inside code. Also note id like to do this either via C or Python. Regards Paul ...

What are C based Services and Java based Services?

What are C based services and Java based services in Android? What is similarity and dissimilarity between them ? Are C based services available in Android? ...

Why Floating point numbers cant be compared?

Possible Duplicate: strange output in comparision of float with float literal #include<stdio.h> int main() { float me = 1.7; if(me==1.7) printf("C"); else printf("C++"); } Output: C++ Now the reason for this behaviour is said that many floating point numbers cant be represented with absolute precision in binary. My...

Meaning of char arr[0]

Possible Duplicate: Array of zero length I have seen such type of code :- #include <stdio.h> #include <stdlib.h> #include <string.h> struct pkt { int pk_type; int tag; int magic_num; char data[0]; <-------- what does this mean ??? }__attribute__((packed)); typedef struct pkt p_t; int main(void) { p_t *p = (p_t *)...

libxml2 - insert child node before parent node's content

I'm using libxml2 to parse HTML. The HTML might look like this: <div> Some very very long text here. </div> I want to insert a child node, e.g. a header, in before the text, like this: <div> <h3> Some header here </h3> Some very very long text here. </div> Unfortunately, libxml2 always adds my header after t...

Delete a record from a file?

i am using a text file to store my data records. the data is stored in the following format. Antony|9876543210 Azar|9753186420 Branda|1234567890 David|1357924680 John|6767676767 Thousands of records are stored in that file. i want to delete a particular record, say "David|1357924680". I am using C, how to delete the particular record e...

Why is this program segfaulting?

I've written a program called Mathtext. This program gives plain text "style" by shifting certain character ranges into Unicode ranges such as 'mathematical letterlike symbols" to produce plain-text italics, bold, serif, etc. It works as a line-by-line interpreter, like a shell, outputting the translated line after a line is entered. Th...

standalone grammar and parser for php

i'm looking for a ready-made grammar and parser for php (at least 5.2), ideally an utility/library that can parse php code into a readable AST, e.g. xml. The parser itself doesn't have to be written in php, the source language doesn't matter much. ...

Regular expression for constants in C

I want to write regular expression for constants in C language. So I tried this: Let digit -> 0-9, digit_oct -> 0-7, digit_hex -> 0-9 | a-f | A-F Then: RE = digit+ U 0digit_oct+ U 0xdigit_hex+ I want to know whether I have written correct R.E. Is there any other way of writing this? ...

Catching exit(#) from C library in C#

Hey, I'm using C# to consume a C library using the following syntax: [DllImport("clib.so") static extern int func(char* foo); I'd like to know if there's any way to catch an exit(#) that happens in the C code so I can reload the library if a critical error ever happens. Thanks! ...

Does either ANSI C or ISO C specify what -5 % 10 should be?

I seem to remember that ANSI C didn't specify what value should be returned when either operand of a modulo operator is negative (just that it should be consistent). Did it get specified later, or was it always specified and I am remembering incorrectly? ...

How to draw anti-aliased circle with iPhone OpenGL ES

There are three main ways I know of to draw a simple circle in OpenGL ES, as provided by the iPhone. They are all based on a simple algorithm (the VBO version is below). void circleBufferData(GLenum target, float radius, GLsizei count, GLenum usage) { const int segments = count - 2; const float coefficient = 2.0f * (float) M_PI / ...

Converting int, double to char array in C or Objective C

I want to convert int to char array and double to char array. Any way of doing this in C or Objective C. ...

How to clean up a bad OpenSSL connection

If a call to SSL_accept fails, I want to just bail out. Currently I'm calling SSL_shutdown and then SSL_free, but since implementing this, two customers have had crashes deep down in OpenSSL (when calling SSL_accept at a later time), so I'm guessing maybe this isn't the best way to clean up. The docs say SSL_shutdown is used to correct...

Why does MAKEINTRESOURCE() work?

Hi, The macro is defined as: #define MAKEINTRESOURCEA(i) ((LPSTR)((ULONG_PTR)((WORD)(i)))) #define MAKEINTRESOURCEW(i) ((LPWSTR)((ULONG_PTR)((WORD)(i)))) How come this can be used to indicate either a resource ID (a 16-bit unsigned int) or its name (a pointer to an array of char)? Doesn't this effectively limit the address space (on ...

Programmatically creating VS solution/project files

I have a C project with a very nice rake build system in place. Unit test runners, mocks, as well as some boilerplate code, are generated. The requirement is for the pc based stuff to be available in VS. I know the VS .sln and .proj formats are undocumented. I also know that cmake can generate VS solution files as long as it's own file...

How to write a C or C++ program to act as a memory and CPU cycle filler?

I want to test a program's memory management capabilities, for example (say, program name is director) What happens if some other processes take up too much memory, and there is too less memory for director to run? How does director behave? What happens if too many of the CPU cycles are used by some other program while director is runn...

How to design a program so the GUI and program logic are decoupled

I'm starting to make my first C program in awhile using GTK+. I've learned C to some extent and I've worked with PyGTK, so I have a decent understanding of both. But, I've never created GUI program with C. Though it worked, my last GUI program was a bit of a mess because the program logic was all mixed in with the GUI stuff. I've read t...

Request terminal size [C - Linux]

I'm trying to make a nice looking terminal game, but a lot of the things i'd like to do need a constant screen size. So i need the program to request a certain size every time it is ran. Is this possible, if so how? ...