Original Question
What I'd like is not a standard C pre-processor, but a variation on it which would accept from somewhere - probably the command line via -DNAME1 and -UNAME2 options - a specification of which macros are defined, and would then eliminate dead code.
It may be easier to understand what I'm after with some examples:
#ifd...
I'm reading The C Programming Language and learned how to make a reverse Polish calculator using a stack. Here is one of the exercises that follow it:
Exercise 4-4. Add the commands to print the top elements of the stack without popping, to duplicate it, and to swap the top
two elements. Add a command to clear the stack.
What do ...
So I have been a .Net developer for the past decade and am thinking of learning either C or C++ (with a strong preference to C++).
Does anyone know a good place where a C# fanboi can get started learning C++ (or C)? With so many tutorial sites on the web, it hard to know where to start, and if there is one which might be more accomodat...
I need to encrypt an ISO 8583 message... the problem here is that the message is longer than the key. I need some one help me how to encrypt this string.
For example: I have 300 chars in my string; should I encrypt each 16 chars alone then concat them, since my master key length is 16 bytes?
I appreciate your help...
ISO 8583-1:20...
Hi,
I wanted to know at which line number are the declarations in a given C function.
Also which lines have if/while/for loops or which lines span multiple lines (ie they
donot end on same line).
...
Hey guys, question from a C/Networking newbie...
I'm doing some socket programming in C and trying to wrestle with byte order problems. My request (send) is fine but when I receive data my bytes are all out of order. I start with something like this...
char * aResponse= (char *)malloc(512);
int total = recv(sock, aResponse, 511, 0);
...
Today, I noticed that when I cast a double that is greater than the maximum possible integer to an integer, I get -2147483648. Similarly, when I cast a double that is less than the minimum possible integer, I also get -2147483648.
Is this behavior defined for all platforms?
What is the best way to detect this under/overflow? Is put...
Is it possible to compute the ranges of float, double and long double data types in a portable way without reading float.h and using ANSI C? By portable, I mean including those cases when the target machine does not adhere to IEEE 754 standard.
I'm reading the K&R book and exercise 2-1 asks me to "compute" them so I suppose that means a...
I heard that some languages go from interpreted to compiled by "unrolling the interpreter loop".
Let's say I have the following pseudo-c-code interpreter for an ast tree.
int interpret(node)
{
switch(node) {
case PLUS:
return interpret(child(0))+interpret(child(1));
case MINUS:
return inter...
What prerequisites are needed to do strict Unicode programming?
Does this imply that my code should not use char types anywhere and that functions need to be used that can deal with wint_t and wchar_t?
And what is the role played by multibyte character sequences in this scenario?
...
I am writing a (my first) C++ class on top of some code written in C, but I can only get the C++ to compile by declaring the C functions in a extern block. My project uses autotools; is there any way to automate this process so I don't have to maintain two header files?
...
What are some good tools for getting a quick start for parsing and analyzing C/C++ code?
In particular, I'm looking for open source tools that handle the C/C++ preprocessor and language. Preferably, these tools would use lex/yacc (or flex/bison) for the grammar, and not be too complicated. They should handle the latest ANSI C/C++ defi...
I've been working with the SpiderMonkey C API and would like to implement a closure in C using their API. The one I would like to implement is fairly complex, but I can't even figure out how to do a simple one such as:
function x() {
var i = 0;
return function() { i++; print(i); };
}
var y = x();
y(); //1
y(); //2
y(); //3
I w...
I'm want to learn one of the above languages. I'm a PHP/HTML/CSS programmer and I would like to get into desktop applications. I need something pretty powerful and I would like to be able to create applications with Windows GUI's.
What would the Stack Overflow community recommend? Is there any knowledge I should have before diving into...
Working with a program that uses 16bytes 4v4 one byte matrices :
unsigned char matrix[4][4];
and a few 256bytes 16v16 one byte matrices:
unsigned char bigMatrix[16][16];
Very often due to data manipulation I am forced to loop column wise in the program making cache misses.
Will the performance improve if I use an array instead, i....
Hi all,
As part of a course assignment i need to write an exploit code to cause a buffer overflow and execute code that is present on stack.
I have turned off the stack randomiztion by the following command:
sysctl -w kernel.randomize_va_space=0
However, i am unable to find a way to turn off the stack execution protection. I am not sur...
Profiling my program and the function print is taking a lot of time to perform. How can I send "raw" byte output directly to stdout instead of using fwrite, and making it faster (need to send all 9bytes in the print() at the same time to the stdout) ?
void print(){
unsigned char temp[9];
temp[0] = matrix[0][0];
temp[1] = ma...
In main:
char *myData[500][9]; //dynamic rows??
char **tableData[500]={NULL}; //dynamic rows??
int r;
newCallBack(db, &myData, &tableData, &r);
and passing into function by:
void newCallBack(sqlite3 *db, char** mdat, char*** tdat, int* r )
{
Doesn't seem to like this? Any suggestions? Lots of examples online when you don...
I'm writing a program in C for Linux on an ARM9 processor. The program is to access network packets which include a sequence of tagged data like:
<fieldID><length><data><fieldID><length><data> ...
The fieldID and length fields are both uint16_t. The data can be 1 or more bytes (up to 64k if the full length was used, but it's not).
...
I'm looking at the poll() man page, and it tells me the behaviour of poll() when positive and negative values are passed in for the timeout parameter. It doesn't doesn't tell me what happens if timeout is 0. Any ideas?
Looking at the epoll_wait() man page, it tells me that with a timeout value of 0, it will return right away, even if th...