c

Parsing XML in C from a DTD and building a linked-list accordingly...

I'm trying to parse an XML file using C. The DTD for this XML file is fairly simple. It's basically a bunch of key-value pairs, with support for arrays as well. I've found XML parsers like Mini-XML and AsmXml, but they don't seem to support building a linked-list of the XML file based on the DTD. Is there an XML parsing library availab...

How to assign a value to a char* using hex notation ?

I usually use pointers in the following manner char *ptr = malloc( sizeof(char) * 100 ); memset( ptr, 0, 100 ) ; strncpy( ptr, "cat" , 100 - 1 ); But this time instead of using "cat", I want to use it ASCII equivalent in hex. cat = 0x63, 0x61, 0x74, 0x00 I tried strncpy( ptr, "0x630x61" , 100 - 1 ); But it f...

calling c from php

I was wondering if there was a way to call existing C code from php? ...

C, Dealing with variable argument functions

Let's say I want to do something like this void my_printf(char *fmt,...) { char buf[big enough]; sprintf(buf,fmt,...); } What is the proper way of passing the variable number of arguments directly to a function with accepts variable arguments? ...

Static and global variable in memory

Are static variables stored on the stack itself similar to globals? If so, how are they protected to allow for only local class access? In a multi threaded context, is the fear that this memory can be directly accessed by other threads/ kernel? or why cant we use static/global in multi process/ thread enviornment? ...

Listing C Constants/Macros

Is there a way to make the GNU C Preprocessor, cpp (or some other tool) list all available macros and their values at a given point in a C file? I'm looking for system-specific macros while porting a program that's already unix savvy and loading a sparse bunch of unix system files. Just wondering if there's an easier way than going hun...

How to create threads and sort correctly in a odd-even sorting program?

I am trying to implement the odd-even transposition sorting algorithm in c with multi-threading. The program will receive a file with a line of integers that need to be correctly sorted. I have created the array that the program will work with and I am reading in the data correctly. Although, I am not quite sure how to create the threads...

Are there any platforms where using structure copy on an fd_set (for select() or pselect()) causes problems?

The select() and pselect() system calls modify their arguments (the 'fd_set *' arguments), so the input value tells the system which file descriptors to check and the return values tell the programmer which file descriptors are currently usable. If you are going to call them repeatedly for the same set of file descriptors, you need to e...

trying to make a "Hello Word" dll in Visual Studio that Java Native Access will accept

I've successfully compiled my library on Linux and Mac and used it with Java Native Access. Unfortunately nothing I do seems to work with Visual Studio's compiler and Java Native Access. I'm going back to the basics and trying to create a super simple dll in Visual Studio that Java Native Access will work with, any help would be appreci...

how is definition of a function after its use in a function call interpreted?

Consider this code: int main() { int e; prn(e); return 0; } void prn(double x,int t) { } Why does this code gives following warnings and no errors? m.c:9: warning: conflicting types for ‘prn’ m.c:5: note: previous implicit declaration of ‘prn’ was here Shouldn't it give a "undefined function" error? ...

Reliably splitting lines out of a string

I'm writing myself a small server daemon in C, and the basic parts like processing connects, disconnects and receives are already in, but a problem in receiving still persists. I use "recv" to read 256 bytes at once into a char array, and because it can contain multiple lines of data as one big chunk, I need to be able to split each lin...

Understanding type casting in c.

I'm following a book on c, and I come to some code that reads a file with 3 lines of text. #include <stdio.h> int main (int argc, const char * argv[]) { FILE *fp; int c; fp = fopen( "../../My Data File", "r" ); if ( NULL == fp ) { printf( "Error opening ../My Data File" ); } else { while ( (c = ...

How can I run an external program without waiting for it to exit?

Hi - I'm trying to execute an external program from inside my Linux C++ program. I'm calling the method system("gedit") to launch an instance of the Gedit editor. However my problem is while the Gedit window is open, my C++ program waits for it to exit. How can I call an external program without waiting for it to exit? ...

What is C's analogy to LabVIEW's Event Structure?

One programming construct I use quite a bit in LabVIEW is the Event Structure. This gives me the benefit of not having to needlessly waste CPU cycles via polling but only perform actions when an event I'm interested in is generated. As an experienced LabVIEW programmer with a decent understanding of C, I'm curious how one would go ab...

What is the best way to achieve `sscanf`-like functionality in perl?

What is the best way to achieve sscanf-like functionality in perl? I am looking now looking at the sscanf module, Which is better, Option-1: Going sscanf way? Option-2: Regex way? [I am a beginner when it comes to Regex] ...

Disable full keyboard and mouse when console of c is running in window OS

Is it possible to disable full keyboard and mouse when I run my c program in window OS. Kindly guide me how can I make it possible. ...

Hide Console of c program in window OS

I want to hide my console of c when I run my application, kindly guide me how can I make it possible so that my application run in the background. ...

C warning 'return' with no value, in function returning non-void.

I have this warning. warning : 'return' with no value, in function returning non-void. ...

Easiest way to transfer data between 2 C programs?

In ANSI C on Windows what is the best/easiest way to transfer data between two programs running locally without needing to write/read from a file? Data will be basic text and only one program will be sending and the other receiving. Thanks. ...

C - Rounding integer division up (instead of truncating)

I was curious to know how I can round a number to the nearest tenth whole number. For instance, if I had: int a = 59 / 4; which would be 14.75 calculated in floating point; how can I store the number as 15 in "a"? ...