c

Why is there no Z80 like LDIR functionality in C/C++/rtl?

In Z80 machine code, a cheap technique to initialize a buffer to a fixed value, say all blanks. So a chunk of code might look something like this. LD HL, DESTINATION ; point to the source LD DE, DESTINATION + 1 ; point to the destination LD BC, DESTINATION_SIZE - 1 ; copying this many bytes LD (HL), 0X20 ...

Architectural Suggestions in a Linux App

Hi, I've done quite a bit of programming on Windows but now I have to write my first Linux app. I need to talk to a hardware device using UDP. I have to send 60 packets a second with a size of 40 bytes. If I send less than 60 packets within 1 second, bad things will happen. The data for the packets may take a while to generate. But if ...

Are there any good and free libraries to develop web applications in C?

I've searched the web a bit, but all I found was abandoned projects and only CGI support. EDIT: C isn't just used for writing drivers or embedded systems. We have mailreaders, newsreaders, editors, etc. all written in C. I've written two BBS in the last century, before the web became popular. The libraries are getting better and you don...

Using the name resolver of resolv.h with IPv6

I write or modify programs which perform name resolution and need a good control of the process. So I do not use getaddrinfo(), I go deeper and use res_query() / res_send() / etc in resolv.h, documented in resolver(3). Although not documented, the common way to set the resolver used is to update _res.nsaddr_list. But this array, define...

Programmatically reading a web page

I want to write a program in C/C++ that will dynamically read a web page and extract information from it. As an example imagine if you wanted to write an application to follow and log an ebay auction. Is there an easy way to grab the web page? A library which provides this functionality? And is there an easy way to parse the page to get ...

Namespaces in C

Is there a way to (ab)use the C preprocessor to emulate namespaces in C? I'm thinking something along these lines: #define NAMESPACE name_of_ns some_function() { some_other_function(); } This would get translated to: name_of_ns_some_function() { name_of_ns_some_other_function(); } ...

Why can I not get system V message queues working with fork()?

I have a program here: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ipc.h> #include <sys/types.h> #include <sys/msg.h> #include <sys/wait.h> #include <errno.h> #include "linkedlist.h" #include "globals.h" #include "card.h" #include "logging.h" #include "stack.h" #include "servers.h" #include "player.h" #de...

System V Msg Queues on Linux don't work as expected.

I have the following application which replicates an issue I'm having in a larger application with system v message queues. basically, the main function generates a key, then creates a message queue with msgget(). Then 3 forks are spawned, each with a different id. each of them runs msgrcv with a different posative number (so they are wa...

how do we call a c function from an sql script

Hi, how do we call a C function from an SQL script? int get_next_fbill_b2kId_seq_num(b2kIdType seq_val,bankIdPtrType bank_id) { validate_dc_alias(dcAlias); tbaDateType sysDate; tbaGetSystemDateTime(sysDate,NULL,NULL); /* returns in TBA date format */ sysDate[10] = EOS; get_seq_value(next_num_char, 0, FBILL_B2KID_SR...

What can I expect to be difference when I transition from C & C# to C++?

Here's a simple question. I've done plenty of work using both C & C# (2.0) but never anything in C++. What can I expect to be different when learning C++? Will there be any big gotcha's or hurdles I should pay attention too? Does anyone good crash course book/website recommendations for learning C++ for the experienced programmer? ...

JPEG support with ijg - getting access violation

Hi all, I was recently trying to update my game to store graphics in compressed formats (JPEG and PNG). Whilst I ended up settling on a different library, my initial attempt was to incorporate ijg to do JPEG decompression. However, I was unable to get even the simplest console application to work and am wondering if anyone might be abl...

How do I obtain a stack trace on Windows without using dbghelp.dll?

How do I obtain a stack trace of addresses on Windows without using dbghelp.dll? I don't need to know what the symbols or function names associated with the addresses, I just want the list of addresses -- something similar to backtrace of *nix systems. Thanks! ...

Turn while loop into math equation?

I have two simple while loops in my program that I feel ought to be math equations, but I'm struggling to convert them: float a = someValue; int b = someOtherValue; int c = 0; while (a <= -b / 2) { c--; a += b; } while (a >= b / 2) { c++; a -= b; } This code works as-is, but I feel it could be simplified into math equ...

How would a loaded library function call a symbol in the main application?

When loaded a shared library is opened via the function dlopen(), is there a way for it to call functions in main program? ...

stack overflow in linux

how to create the condition of stack overflow in linux ...

Yacc Problem: Make Data available in next Non Terminal

Hi! I want to make some variables I generate in b available in c: a : b c { ...some code...} A simple example: b : X { int result = 0; } | Y { int result = 1; } so I can, later on in c say: c : D { printf(result + 1); } | E { printf(result + 2); } Is there any chance to do that? Any help would really be apprecia...

What is the best command-line tool to clean up code?

When I'm writing C - code I solely use an editor and gcc. I was wondering if anyone could suggest a good and simple tool that will find unused variables, function declarations and possibly make some optimisations. Does anybody know a good tool? ...

Counting the number of occurrences of words in a textfile

How could I go about keeping track of the number of times a word appears in a textfile? I would like to do this for every word. For example, if the input is something like: "the man said hi to the boy." Each of "man said hi to boy" would have an occurrence of 1. "the" would have an occurence of 2. I was thinking of keeping a diction...

Socket with recv-timeout: What is wrong with this code?

I'm trying to implement a socket with a recv timeout of 1 Second: int sockfd; struct sockaddr_in self; struct sockaddr_in client_addr; int addrlen=sizeof(client_addr); ssize_t nBytes; sockfd = socket(AF_INET, SOCK_STREAM, 0); self.sin_family = AF_INET; self.sin_port = htons(PORT); self.sin_addr.s_addr = INADDR_ANY; int on = 1; setso...

Does using lists of structs make sense in cocoa?

This question has spawned out of this one. Working with lists of structs in cocoa is not simple. Either use NSArray and encode/decode, or use a C type array and lose the commodities of NSArray. Structs are supposed to be simple, but when a list is needed, one would tend to build a class instead. When does using lists of structs make sen...