c

Two 'main' functions in C/C++

Can i write a program in C or in C++ with two main functions? ...

Role of C,C++,python,perl in Web development

Please bear with me experts i'm a newbie in web dev. With html,css can take care of webpages.. javascript,ajax for some dynamic content.. php for server side scripting,accessing databases,sending emails,doing all other stuf... What role do these programming languages play? Can they do any other important task which cannot be done by PH...

How to Code a Solution To Deal With Large Numbers?

I'm doing some Project Euler problems and most of the time, the computations involve large numbers beyond int, float, double etc. Firstly, I know that I should be looking for more efficient ways of calculation so as to avoid the large number problem. I've heard of the Bignum libraries. But, for academics interests, I'd like to know how...

Find all combinations of a given set of numbers

Hi, say I have a set of numbers '0', '1', '2', ..., '9'. I want to find all numbers that contain exactly one of each of the numbers in my set. The problem is: Before I start my program, I do not know how many numbers and which numbers my set will include. (For example, the set could include the numbers '1', '3' and '14'.) I searched t...

arduino web client class not working

I am trying to use arduino client class to fetch an html page from internet (Example from arduino library itself), but it's not working (Connection is not getting established). It's failing at: client.connect(); I have tried both Ethernet and Ethernet2 libraries. My arduino development platform version is 0017 , OS is win XP. Follo...

How to add records (struct) in a function in the C programming language?

How do you add a record if you send as a parameter to a function? struct record { char name[20]; int nr; }; void AddRecord(struct record **p_allRecs, int p_size); int main() { struct record *allRecs; /* putting in some records manually, size++... */ allRecs = (struct record *)malloc(size*sizeof(struct record)); } AddRecord(&allRecs,...

what kind of loop is for (;;)?

found in torvalds/linux-2.6.git -> kernel/mutex.c line 171 i have tried to find it on google and such to no avail. what does "for (;;)" instruct? ...

Variable argument lists in C functions - How to properly iterate through the arg list?

In the following C program i get the warning: warning #2030: '=' used in a conditional expression. What exactly is the problem and how do i avoid this? What is the correct way to iterate through the variable arguments? #include <stdio.h> #include <stdarg.h> int Sum(int a, int b, ...) { int arg; int Sum = a + b; va_list...

Languages with direct C compatibilty

Apart from C++, which non-toy languages have direct or easy-to-use compatibility to C? As in "I can take a C library out there, and compile my code against it without having to find, write, or configure some kind of wrapper." I know that lots of languages have compatibility with C through some form of external call or binding (I've be...

A pure bytes version of strstr?

Is there a version of strstr that works over a fixed length of memory that may include null characters? I could phrase my question like this: strncpy is to memcpy as strstr is to ? ...

why c is preferred instead of java in most of the real time appliaciotn.

why c is preferred instead of java in most of the real time appliaciotn. for example like air line system. i want the some of the reasons except that java is little slow. ...

C API with Mysql in XCode

Dear All, Setup: Running Mac OSX Snow Leopard, X Code 3.2.1, Mysql 5.1.42 and Mysql C-Connector 6.0.2, all 64-bit. I am having real difficulty configuring X-Code to run Mysql scripts. XCode is running fine (i.e. can Build and Run), MySQL server is running and I am confident on the installation of the programs listed under my Setup at t...

Question about fork()

Hi, this is my function: void connection(int sock) // sock is a descriptor of socket { char buffer[MAX]; int n; // number of bytes read or write into a socket int f; f = fork(); if(write(sock,"HELLO\n", 5) < 0) { perror("Error: \n"); } write(sock, "\n> ",3); do { memset(buffer,'0',M...

How do I sort the symbols of other sections besides the "COMMON" section?

The gnu linker "ld" supplies the option "-sort-common" which sorts the uninitialized global parameters, known as the COMMON section symbols, by their size. When the linker aligns the symbols to even addresses, this option helps minimizing the holes in the section. For example, if we define: --main.c char a; short b; ch...

File Operations in Android NDK

I am using the Android NDK to make an application primarily in C for performance reasons, but it appears that file operations such as fopen do not work correctly in Android. Whenever I try to use these functions, the application crashes. How do I create/write to a file with the Android NDK? ...

string reversal recursively

Ok, i wrote 2 versions of this program. But im looking for the best solution - the most simple and fast one. This is my solution but i was told that this solution is O(n*n) slower, which i dont know what really means. I was also told i could fasten it by breaking it into 2 functions, could anyone help me doing this? void reverse3(char ...

Static linking vs dynamic linking

Are there any compelling performance reasons to choose static linking over dynamic linking or visa versa in certain situations? I've heard or read the following, but I don't know enough on the subject to vouch for their veracity. 1) The difference in performance between static linking and dynamic linking is usually negligible. 2) (1) i...

itoa recursively

Ok, well i have been trying to write a recursive version of itoa, this is what i came up with. void itoa(int n, char s[]) { static int i = 0; if(n / 10 != 0) itoa(n/10, s); else if(n < 0) i = 1; /* s[0] is allready taken by - sign */ else i = 0; /* reset i to 0 */ if(n < 0) { ...

translate this block of C physics code to python

Hi all, I have only learnt python for for few months and totally a newb in C, I got a C code from the web, and I am dying to study it. But i only understand python language, so would someone can help to translate the following code to python would be great. Thanks in advance! for(i=0; i<n; i++) { /* Foreach particle "i" ... */ ax=0.0;...

C win32 wrapper

I'm developing a win32 app in the C Programming Language. This is my first experience with the native win32 apis and they seem to be completely brutally unreadable (simple window). I was wondering if there was a wrapper for the entire API that I could use, instead of having to smash my head with this stuff. Other frameworks/libs won't ...