c

Solving a system of equations programmably?

Possible Duplicate: System of linear equations in C++? I have the following 2 systems of equations: For a,b,c,d: 0 = a * r1_x + b * r1_x * r1_y + c * r1_y + d 1 = a * r2_x + b * r2_x * r2_y + c * r2_y + d 0 = a * r3_x + b * r3_x * r3_y + c * r3_y + d 1 = a * r4_x + b * r4_x * r4_y + c * r4_y + d For e,f,g,h: 0 = e * r1_x ...

Learning C - Pointers and memory addressing

I am learning C programming and I have a simple question about pointers... I used the following code to play around with pointers: #include <stdio.h> int main (int argc, const char * argv[]) { int * c; printf("%x\n",c); return 0; } When I print the value of C, I get back a 0. However, when I print &c (i.e. printf("&x\n",&c) I get ...

Expression for struct creation

Is is possible in C to create structs “inline”? typedef struct { int x; int y; } Point; Point f(int x) { Point retval = { .x = x, .y = x*x }; return retval; } Point g(int x) { return { .x = x, .y = x*x }; } f is valid, g not. Same applies to function calls: float distance(Point a, Point b) { return 0.0; } int ...

How to implement getch() function of C in Linux?

In turbo c++, we can use getch() function available in conio.h. But in linux, gcc compiler doesn't provide conio.h header file, then how to get functionality of getch() function? ...

Progamming / memory / logical issue in code

Can you tell me is there any thing wrong in the code, my application is crashing randomly I cannot find any possible logical or memory error, please help as this is going out of my scope. #define __FN__ "CGD9_gd_ParseAddFieldsProC" int CGD9_gd_ParseAddFieldsProC (CGD_gd_ParseAddFields_Iparam_t *i_param_st_p) { t_gd9adfld_t *p_ext_fi...

Reversing words in a sentence

I'm currently going through K.N. King's C Programming: A Modern Approach. I've made it past the text for the 8th chapter (Arrays), and I'm eager to move on to chapter 9, but I've yet to solve the so-called "programming projects" at the end of each chapter. Unfortunately, the 14th... bugs me. Write a program that reverses the words in...

Is SIMD Worth It? Is there a better option?

I have some code that runs fairly well, but I would like to make it run better. The major problem I have with it is that it needs to have a nested for loop. The outer one is for iterations (which must happen serially), and the inner one is for each point particle under consideration. I know there's not much I can do about the outer on...

Accessing lower half of a 64bit integer

How can access the lower half of a 64bit integer using C or C++? I can do it easily in Assembly but I have no clue on how to do it in C/C++ EDIT: What about accessing the upper half? ...

Fixed-point multiplication in a known range

Hi, I'm trying to multiply A*B in 16-bit fixed point, while keeping as much accuracy as possible. A is 16-bit in unsigned integer range, B is divided by 1000 and always between 0.001 and 9.999. It's been a while since I dealt with problems like that, so: I know I can just do A*B/1000 after moving to 32-bit variables, then strip back to...

How can I best deploy a web application written in C?

Say I have fancy new algorithm written in C, int addone(int a) { return a + 1; } And I want to deploy as a web application, for example at http://example.com/addone?a=5 which responds with, Content-Type: text/plain 6 What is the best way to host something like this? I have an existing setup using Python mod_wsgi on Apache2,...

How to rollback lines from cout ?

Hi, I'm coding a task monitoring, which updates tasks' progress using cout. I'd like to display one task progress per line, therefore I have to rollback several lines of the console. I insist on "several" because '\b' does the job for one line, but does not erase '\n' between lines. I tried std::cout.seekp(std::cout.tellp() - str.leng...

Creating a SSH connection in a program?

Hi all, I am writing a programing (in C) in which I have to access data from another computer through an SSH connection. I was wondering how to create the SSH connection within the program. Thanks ...

Reasons to choose C over C++

Possible Duplicate: Whats the advantage of using C over C++ or is there one? Hello all. I was wondering why so many people continue to code in C when C++ has now been out for such a long time. What advantages/disadvantages are there?? I heard that there are differences (ie. advantages to C) in the way that linking is done, b...

Post-Increment Operator: Unexpected Behavior

Possible Duplicate: Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc) My code is as follows: #include <stdio.h> int main() { int x = 10, y = 0; x = x++; printf("x: %d\n", x); y = x++; printf("y: %d\n", y); } Given the nature of post-increment, I would expect the following output: x: 10...

Using the ANTLR C target, how can I get the previously matched token in the Lexer?

I have a relatively complicated lexer problem. Given the following input: -argument -argument#with hashed data# #plainhashedData# I need these tokens: ARGUMENT (Text = "argument") ARGUMENT (Text = "argument") EXTRADATA (Text = "with hashed data") OTHER (Text = "#plainhasheddata#") I've been able to take care of the text manipulatio...

Extract x509 cert and private key from pkcs12 file

I want to extract x509 cert and private key from pkcs12 file using a C lib. I found lot of .net utils to do this, but did not find any C libraries. My code will run in WinPE environment, so .net will not work. ...

Is there a way to get destination mac addres in ANSI C

Is there a way to get the destination MAC address, if the destination IP is known, using ANSI C? I would preferably do it with a system call so the kernel deals with it all and I can take advantage of the ARP cache. I know I can build and send my own ARP request, but then I would not have the caching functionality etc unless I implement ...

trying to understand the c preprocessor

why do these blocks of code yield different results? some common code: #define PART1PART2 works #define STRINGAFY0(s) #s #define STRINGAFY1(s) STRINGAFY0(s) case 1: #define GLUE(a,b,c) a##b##c STRINGAFY1(GLUE(PART1,PART2,*)) //yields "PART1PART2*" case 2: #define GLUE(a,b) a##b##* STRINGAFY1(GLUE(PART1,PART2)) //yields "works*"...

I want to call one command(user defined) from C program(Windows)

I want to call one command(user defined) from C program(Windows). Can you tell me the function available? ...

Rounding in C Preprocessor

Hi, I am defining some values in the preprocessor. e.g. #define a 1000 #define b 0.5*a when I try to use b in a place where integer is needed I get an error. I don't want to cast b always in my code and do it once in the #define line, is that possible? ...