c

Convert Hex to Decimal when no datatype can hold the full number

Ok, so I am working with a PIC microprocessor, in C. It's a 16F, so it can't hold integers larger than 32bits (unsigned int32 is the largest datasize available) From a reader, I receive a 5 byte ID code. To transmit it, I have to encoded to BCD, digit by digit. I can't sprint it to a string, as it is larger that the data size, and can't...

gtk_menu_item_new_with_labelex vs gtk_menu_item_new_with_label

what is the difference between these two function calls: menu_item_new_with_labelex vs gtk_menu_item_new_with_label ...

How to safely remove orphaned values in the Windows registry?

I had an application installed on my windows machine which I removed, but it has left an orphaned drive icon under "My Computer". Having dug through the registry, to find it by name, it seems to be associated with a GUID that occurs in other parts of the registry. I'd like to write a quick C program to do the job, once I understand wha...

How to extract a single function from a source file

Hi, I'm working on a small academic research about extremely long and complicated functions in the Linux kernel. I'm trying to figure out if there is a good reason to write 600 or 800 lines-long functions. For that purpose, I would like to find a tool that can extract a function from a .c file, so I can run some automated tests on the ...

Buffer Overflow (vs) Buffer OverRun (vs) Stack Overflow

Possible Duplicate: What is the difference between a stack overflow and buffer overflow ? What is the difference between Buffer Overflow and Buffer Overrun? What is the difference between Buffer Overrun and Stack Overflow? Please include code examples. I have looked at the terms in Wikipedia, but I am unable to match with pr...

Portability of dlfunc?

I'm reading through the manpage for dlopen and friends on FreeBSD. I'm working on a cross-platform application that is using shared libraries for loadable plugins. I've never done this before, but I think I have a decent grasp of how it works. The manpage mentions dlsym(), which appears to be the common means of getting a function pointe...

Have you written very long functions? If so, why?

Hi, I am writing an academic project about extremely long functions in the Linux kernel. For that purpose, I am looking for examples for real-life functions that are extremely long (few hundreds of lines of code), that you don't consider bad programming (i.e., they won't benefit from decomposition or usage of a dispatch table). Have y...

sprintf and char [] vs. string

I need to pass const char * to a function. Before I pass it, I usually need to build it from some variables. I can never decide which approach is more elegant, and overall better: Allocate an array long enough to fit the text and use sprintf to build the final variable and pass it to the function. Initialize string s with a variable us...

Move between two points in an output file

Hello everyone! I am writing a C program that produces a large output file. To increase readability, I would like to collect certain kinds of output at certain points in the file rather than have it be scattered randomly about. Consider a file like: log log (a) output output output(b) Say the program is currently writing the line a...

#define directive question

Hi, I've got the following code: #define checkLiteMessage \ { \ #ifdef LITE_VERSION \ if (alertView.tag == 100) \ { \ if (buttonIndex == 1) \ [ [UIApplication sharedApplication] openURL: buyAppLink]; \ [alertView release]; \ return; \ } \ #endif \ } \ What I want to do is to have the fol...

sending C structures to a future version of your code?

I'm working on a hot-upgrade feature and need to package up an array of structs to be stashed away for the new version to find them. I really want to avoid adding a conversion function for every possible version transition. Is this reasonable? The most likely change to the struct is for more fields to be added to the structure in the f...

C/C++ Thread-safety of tmpnam?

I need to use the tmpnam function in C++, but I need to know about its thread safety. Namely, If I have several threads which will each need to acquire a different name for a temporary file, am I guaranteed that each thread will receive a file with a different name? ...

How to download web resource using Digest authentication

What set of Windows API calls will allow downloading a web resource (specifically an XML document) when the site is protected using Digest authentication without having to enter a username and password? I can use MSXML's “open” function on the IXMLHTTPRequest interface, but it requires a username and password to be supplied even thoug...

Static code analyzers for C

Which static code analyzer (if any) do you use? I've been using PyLint for Python and I'm pretty satisfied with it, now I need something similar for C code. How much of it's output do you have to suppress for normal daily usage? ...

Emacs, xterm, mousepad, C, Unicode and UTF-8: Trying to make sense of it all

Disclaimer: My apologies for all the text below (for a single simple question), but I sincerely think that every bit of information is relevant to the question. I'd be happy to learn otherwise. I can only hope that, if successful, the question(s) and the answers may help others in Unicode madness. Here goes. I have read all the usually ...

Why can't I build a "hello world" for glib?

So here's the world's simplest glib program: #include <glib.h> I try to compile it with gcc test.c and I get: test.c:1:18: error: glib.h: No such file or directory So I make sure that I have the right packages: # dpkg -l | grep libglib ii libglib-perl 1:1.183-1 Perl inter...

C Languages Family names

Why is C language called "C". Is C stands for "Compiler"? Another question: Why C++ has two pluses? is it because it is Second version of C? What about C#, is # stands for four pluses (++++)? Is there going to be something else in the future, something like C~ or C*. ...

How to calculate the Rect of a row of N boxes filling up a length L with S space between them

This problem must have been solved a million times, but Google has not been my friend. I need to programmatically space a set of boxes to fill a certain length and be separated by a certain distance. This is what I want: Here is what I'm getting: Since I'm working in Objective-C using Core Graphics, I need a series of Rects that...

SQL parser in C

I want to parse and store the columns and values of a SQL DML (INSERT, UPDATE, DELETE) statement in C. Need the URL of the open source code or a library with which I can link my C program. The platform is SUSE Linux. Have tried to make and use libSQL unsuccessfully. A detailed answer is appreciated. Thanks. Additional Notes: Please sugg...

Create instance of a python class , declared in python, with C API

Hello, I want to create an instance of a Python class defined in the __main__ scope with the C API. For example, the class is called MyClass and is defined as follows: class MyClass: def __init__(self): pass The class type lives under __main__ scope. Within the C application, I want to create an instance of this class. ...