I'm considering using Go as a low-level, performant language alternative to C/Objective-C to implement a library for an iPhone App. Could either of the Go compilers generate a library that could be linked into a native iPhone app with the Go runtime, etc.? Is there an ARM port for Go or does gccgo/gcc support this? I imagine that since g...
Is the wchar_t type required for unicode support? If not then what's the point of this multibyte type? Why would you use wchar_t when you could accomplish the same thing with char?
...
I recall a quote that goes something like this:
Unix is the universal virtual machine and C is its scripting language.
I am looking for the origin of this quote and the exact language. I vaguely remember Eric Raymond as the proximate source, but I can't find it in his writing.
...
I have created a 2 d array which reads as follows
int i,j,lx,ly;// lx,ly are the row and column respectively
double** a;
a=(double**) malloc((lx+2)*sizeof(double));
a[0]= (double*) malloc((lx+2)*(ly+2)* sizeof(double));
assert(a[0]);
for(i=1;i<lx+2;i++)
{
a[i]=a[i-1]+i*(ly+2);
}
// I...
Hi everyone:
This is my first attempt on semaphores and threads.
I constructed this code from examples and the man pages found on the Net.
I have two doubts with this code.
Why do I get a Bus error whenever I try semctl( I know this is the root of the problem because of the debug line 3 does not get printed) and how to prevent it?
Wh...
Possible Duplicate:
newbie questions about malloc and sizeof
I am trying to read strings into a program. When I noticed that the strings were sometimes being corrupted, I tried the following code:
void *mallocated = malloc(100);
printf("sizeof(mallocated) = %d\n", sizeof(mallocated));
According to my program, the size of...
Hi,
I have this code
#define BUFFER_LEN (2048)
static float buffer[BUFFER_LEN];
int readcount;
while ((readcount = sf_read_float(handle, buffer, BUFFER_LEN))) {
// alsa play
}
which reads BUFFER_LEN floats from buffer, and returns the number of floats it actually read. "handle" tells sf_rad_float how big buffer is.
E.g. if buffer...
Possible Duplicate:
How can I run an external program from C and parse its output?
Hi,
Could someone please tell us how to capture a result when executing system() function ?
Actually I wrote a c++ program that displays the machine's IP address, called "ipdisp" and I want when a sever program executes this ipdisp program, t...
Inspired by this question,
Now visible only for users with > 10k rep
I came up with the following code:
$cat loop.c
int main( int argc, char ** argv )
{
int i = 0;
while( i++ < 2147483647 );
}
$cc -o loop loop.c
$ time ./loop
real 0m11.161s
user 0m10.393s
sys 0m0.012s
$cat Loop.java
class Loop {
public static v...
Can threads have more than one argument without using a struct?
So... kind of like:
pthread_create(&file_thread, NULL, merge_thread, sortedFiles, number);
... where 'number' is the extra argument?
Thanks,
Hristo
...
What is the shortest C code to "Calculate the n-th prime"?
Shortest in terms of significant characters, i.e. the number of semicolons, non-whitespace characters, keywords and commas.
Input:
Integers n from the standard input, separated by new lines. The input will be terminated by EOF.
Output:
Right after the input n, print the n-th...
I want to do RAD with C, but the only ones I can find only use C++.
...
Right now I am going through a book on C and have come across an example in the book which I cannot get to work.
#include <stdio.h>
#define IN 1
#define OUT 0
main()
{
int c, nl, nw, nc, state;
state = OUT;
nl = nw = nc = 0;
while ((c = getchar()) != EOF) {
++nc;
if (c == '\n')
++nl;
if (c == ' ' || c == '\n' |...
Hi,
I tried to solve problem# 276 from Project Euler, but without success so far.
Consider the triangles with integer
sides a, b and c with a ≤ b ≤ c. An
integer sided triangle (a,b,c) is
called primitive if gcd(a,b,c)=1. How
many primitive integer sided triangles
exist with a perimeter not exceeding
10 000 000?
The bo...
I need an open-source (preferably MIT-licensed) light-weight growable buffer implemented in plain C (preferably also compileable as C++).
I need API equivalent to following (pseudo-code):
void set_allocator(buffer * buf, allocator_Fn fn);
void push_bytes(buffer * buf, const char * bytes, size_t len);
size_t get_length(buffer * buf);
v...
I am writing a server in linux that is supposed to serve an API.
Initially, I wanted to make it Multi-threaded on a single port, meaning that I'd have multiple threads working on various request received on a single port.
One of my friends told me that it not the way it is supposed to work. He told me that when a request is received,...
iam trying my hand at using the crystal space api in my graphics applications.
crystal space website
The applications compile fine but iam having hell with the dlls(dynamic link libraries). The compiled application crashes at run time and i suspect its because of not finding the needed dlls.
The only solution i currently have is cuttin...
I have a bit counting method that I am trying to make as fast as possible. I want to try the algorithm below from Bit Twiddling Hacks, but I don't know C. What is 'type T' and what is the python equivalent of (T)~(T)0/3?
A generalization of the best bit
counting method to integers of
bit-widths upto 128 (parameterized by
type T...
I need a way to notify my user space app when a network interface is enabled or disabled. I'm hoping to do this without resorting to polling. Does the kernel offer some sort of hook for triggering callback functions when network-related events occur?
...
Problem Statement : Sum the positive values in a series of integers.
Input :
t – number of test cases [t < 1000].
On each of next t lines given a integer N [-1000 <= N <= 1000]
Output :
One integer equals to sum of all positive integers.
This is actually a SPOJ problem.I had solved it using python & ruby already but now I am interes...