c

asynchronous memcpy in linux ?

Is there any asynchronous memcpy function in linux? I want it to work with DMA and notify me when it gets completed. ...

C: Initialize module variable

Hello, I got two modules (compile units), both using a module variable with the same name: FileA.c and FileB.c both contain: #includes int m_Test; // Functions That's no problem, both variables are independent, as expected - but as soon as I assign values to the variables like: int m_Test = 0; I get (using VS2008) the error LNK...

How to avoid press enter with any getchar()

Hi, this is a "novato" question for the c programming language: in the next code: #include<stdio.h> int main(void){ int c; while((c=getchar())!= EOF) putchar(c); return 0; } I have to press ENTER to print all the letters I entered with getchar,but I don't want to do this, what I want to do is to press the lett...

In C, missing link between "Main process ends" to "call any functions registered with atexit"

In C, when the main process ends -- how does it know to call any functions registered with atexit()? I understand how atexit() works, but I don't understand the communication between "Main process ending" and "call any functions registered with atexit()" I'm being a bit redundant. Thanks! ...

prior declarations of functions

Why do functions need to be prior declared in C ? ...

Compile Windows C console applications in Linux

Can I compile a Windows C console application (.exe) in Linux? (more specific, Ubuntu) I heard a long time ago of cross-compilers, but I wasn't interested in them at that time. Best regards, John F. ...

Where can I find benchmarks on different networking architectures?

Where can I find benchmarks on different networking architectures? I am playing with sockets / threads / forks and I'd like to know what the best is. I was thinking there has got to be a place where someone has already spelled out all the pros and cons of different architectures for a socket service, listed benchmarks with code that run...

Given a start and end point, and a distance, calculate a point along a line

Looking for the quickest way to calculate a point that lies on a line a given distance away from the end point of the line: void calculate_line_point(int x1, int y1, int x2, int y2, int distance, int *px, int *py) { //calculate a point on the line x1-y1 to x2-y2 that is distance from x2-y2 *px = ??? *py = ??? } Thanks fo...

easy way to display the contents of data structures in C ?

For debugging purposes, I find it useful to display the contents of data structures. (In Python for example, I would just do "print some_dict_name"). Can this be achieved in C this easy too by using a standard library, or do I have to implement this myself depending on the data structure ? Consider the following code, where I have to i...

Reading text file into an array of lines in C

Using C I would like to read in the contents of a text file in such a way as to have when all is said and done an array of strings with the nth string representing the nth line of the text file. The lines of the file can be arbitrarily long. What's an elegant way of accomplishing this? I know of some neat tricks to read a text file dire...

Are there well-defined size limits in FormatMessage?

I am having a problem when arguments passed to FormatMessage are too long. void testMessage(UINT id, ...) { va_list argList; va_start(argList, id); LPTSTR buff = NULL; const char* str = "The following value is invalid: %1"; DWORD success = FormatMessage(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER, ...

Unit Testing - How to go about it?

I want to unit test my program (in C) because I know of the benefits of doing so as well, as it shows where the problem is. I also like to blackbox test, since it tells me if the program works (at least, for the tests). At the moment, I am using Autotest (Which comes with Autoconf) in order to not add a dependency. At this point, I wo...

Comparing character arrays with an == operator in C

I know that the correct way to compare "strings" in C is by using strcmp, but now I tried comparing some character arrays with the == operator, and got some strange results. Take a look at the following code: int main() { char *s1 = "Andreas"; char *s2 = "Andreas"; char s3[] = "Andreas"; char s4[] = "Andreas"; cha...

MySQL and C : undefined reference to `_mysql_init@4'|

I'm trying to write a simple script for C to get values from a MySQL database, but it's throwing this error 'undefined reference to `_mysql_init@4'' Don't know if I'm not linking to something I should be? My C knowledge is limited... I'm using Code Blocks on Windows, here's my code: #include <winsock.h> #include <C:\mysql\include\mys...

C - Dynamically initializing arrays.

I'm trying to find the equivalent of int myArray[n], except I don't know what n is without input. Is the following code supposed to work? (I need to use kmalloc instead of malloc). int * pages; //... later, after we find out n... pages = (int *)kmalloc(npages * sizeof(int)); Debugging using gdb, the value pages[0] doesn't seem to be ...

Is smtplib pure python or implemented in C?

My question is very straight forward: Is smtplib pure python or implemented in C? ...

C/C++: any way to get reflective enums?

I've encountered this situation so many times... enum Fruit { Apple, Banana, Pear, Tomato }; Now I have Fruit f; // banana and I want to go from f to the string "Banana"; or I have string s = "Banana" and from that I want to go to Banana // enum value or int. So far I've been doing this.. Assuming the enum is in Fruit.h: /...

Reverse a singly linked list

I would be wondered if there exists some logic to reverse the linked list using only two pointers. The following is used to reverse the single linked list using three pointers namely p, q, r: struct node { int data; struct node *link; }; void reverse() { struct node *p = first, *q = NULL, *r...

How to create dynamic HTML pages using C?

Hi All, How to create DHTML pages using C language? Please give me some web site where I can find the step by step procedure to create DHTML pages using C. Regards, NM ...

Python - Multi-Dimensional Arrays

Python does not provide built-in support for multi-dimensional arrays. I need to develop an 11-dimensional array and a set of functions to operate on it (mostly linear algebra, vector arithmetics). However, no external library import is allowed. I have a code in C and trying to port it to Python: typedef vec3_t float[3]; vec3_t Array[d...