c

Using multiple modules/types with Python C API?

I've got two different Python extension modules; let's call them A and B. Module A contains a storage class type called container that I want to use within Module B as the return type of a class method. I can't seem to find any documentation on how I'm supposed to do this. I roughly followed this article to create the modules/classe...

Static function-scoped pointers and memory leaks

Hi all, I've written a simple library file with a function for reading lines from a file of any size. The function is called by passing in a stack-allocated buffer and size, but if the line is too big, a special heap-allocated buffer is initialized and used to pass back a larger line. This heap-allocated buffer is function-scoped and d...

How can I define #define in my Make files

Hi, In my c/c++ files, there are multiple #define. As an example: #ifdef LIBVNCSERVER_HAVE_LIBZ /* some code */ #ifdef LIBVNCSERVER_HAVE_LIBJPEG /* some more code */ Can you please tell me how can I modify my Makefile.in so that I have those #define in ALL files during compilation? Thank you. ...

Finding line size of each row in a text file

How can you count the number of characters or numbers in each line? Is there something like a EOF thats more like a End of Line? ...

Heap error in C

I know this is really general, but I get "this" (see below) when I run my .c file in Visual C++ 2008 Express. It happens when I call malloc (). Take my work on this - I dynamically allocate memory properly. HEAP[Code.exe]: HEAP: Free Heap block 211a10 modified at 211af8 after it was freed Windows has triggered a breakpoint in Code...

Perhaps a resource not released? What could cause this?

I'm working on a project and I came to a point where the following stack trace popped up: #0 0x0017c30c in _IO_flush_all_lockp () from /lib/libc.so.6 #1 0x0017d030 in _IO_cleanup () from /lib/libc.so.6 #2 0x0013e042 in exit () from /lib/libc.so.6 #3 0x00126bbe in __libc_start_main () from /lib/libc.so.6 #4 0x08049d11 in _start () ...

How do I print a non-null-terminated string using printf?

How can I print a non-null-terminated string using printf, assuming that I know the length of the string at runtime? ...

ANSI C, integer to string without variadic functions

I'm currently working with a SPC that supports ANSI C, but uses its own flavour of the GNU compiler, which doesn't compile any variadic functions and things like itoa. So using sprintf & co. isn't an option for converting integers to strings. Can anyone guide me to a site where a robust, sprintf- free implementation of itoa is listed or ...

Output to a text file the pre-compiler code

Hello, gcc 4.4.2 c89 I have a file called main.c. I want the result of the pre-comiler and save it to a text file. I have done the following which creates a text file, but there is nothing in it. It is zero bytes. gcc -E main.c | > main.txt Many thanks for any suggestions, ...

How to access a structure variable which is inside a cpp class,from c ?

Sample eg: messageStruct.hpp class MessageStructure_t{ public: struct MsgData_t { float a; int i; }__attribute__((packed))msgdata_m; };//classs end I have a file in my project Application.c. I need to access the structure variables here. Both are different, one .hpp and the other .c How can I do this ? Hoping your kind ...

data structure for adding very large numbers?

how will you add numbers like 1234567890123456789012345678901234567890, which can't be specified using primitive data types? what kind of data structure will you use ? ...

how can i create a pdf file using turbo c? (e.g typing something and save it as .pdf)

can anyone help me on how can i create a pdf file using turbo c? (e.g typing something and save it as .pdf) ...

What does "->" stand for in C programming, Gtk+ programming?

Possible Duplicate: What is the arrow operator (->) synonym for in C++? I couldn't find documentation on the "->" which is used a lot in Gnome codebase. For example in gedit they have this: loader->document = g_value_get_object (value) What is document in relation to loader? There are many other examples as well with more bas...

Swapping elements in an array of structs

Say I have this struct: struct MyStruct { int iID; int iMyNumber; }; Then I define an array of MyStructs: struct MyStruct msTest[3]; I'm doing a sorting operation on a struct similar to this one by looking at the ID. Now, as soon as I find out which records should be swapped to sort the array I have to do the actual swapping. I...

Layout of compiled objects

Is there a waymuch like viewing the result of preprocessing with gcc -Eto see what my objects look like once compiled into object files? I am talking about GCC, but a solution including MSVC would be fine. ...

Can't figure out syntax of compact struct declarations

Neither of these snippets of code work: int main() { struct mystruct { int a; char* b; char* c; } e,f; e = {5, "blaat", "boe"}; return 0; } Error: syntax error for '{' token int main() { struct mystruct { int a; char* b; char* c; } e,f; struct mystruct e...

gcc Can't Find a Included Header

I'm using a header called colors.h to organize my source code. The header is like this: #define DEFAULT 0x07 #define BLACK 0 #define GRAY 7 #define BLUE 9 #define GREEN 10 #define CYAN 11 #define RED 12 #define MAGENTA 13 #define YELLOW 14 I'm putting the header at the same directory of the main source code, called kernel.c, and inclu...

Which NoSQL db to use with C?

Hello all, I'm working on an application that I'm going to write with C and i am considering to use a nosql db for storing timeseries data with at most 8 or 9 fields. But in every 5 minutes there will huge write operations such as 2-10 million rows and then there will be reads(but performance is not as crucial in read as in the write op...

How To Print ASCII Extended Characters Using a Const Char*?

I have a function to print characters on the screen that is like this: void print(int colour, int y, int x, const char *string) { volatile char *video=(volatile char*)0xB8000 + y*160 + x*2; while(*string != 0) { *video=*string; string++; video++; *video=colour; video++; } } And I want to prin...

What is type safety and what are the "type safe" alternatives?

Possible Duplicates: What is Type-safe? What is type-safety? I was reading about c++ vectors and it was mentioned that memcpy and printf functions from C are not type safe. Article here: http://en.wikipedia.org/wiki/Vector_(C%2B%2B). Question: In simple English, what is type safety and what are the "type safe" alternatives? ...