C is a general-purpose computer programming language used for operating systems, games and other high performance work and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.
4
votes
4answers
27 views
Detect 64-bits in C using size_t
Is sizeof(size_t)==8 the equivalent of saying that the platform is 64-bits ?
Conversely, is sizeof(size_t)==4 the equivalent of saying that the platform is 32-bits ?
More importantly, is this test ...
0
votes
2answers
29 views
How to get range like this in an array using C/C++?
For example, there is an array a of size 10 contain data as follow:
0.0
0.01
0.02
0.03
5.04
6.05
7.06
13.07
20.08
22.09
If the step fixed is 5, expected data range are:
start end
0.0 0.03
...
0
votes
1answer
18 views
How to put a character at a specific point in a character array?
I am making a simple tic tac toe game. I've run into problems storing the user's choice.
I basically have a struct called userBoard that has a character array of size 12. The user will be presented ...
3
votes
3answers
50 views
Struct X in Struct X?
this is probably really simple, but how can I get a struct x to be in struct x in C? So for example:
typedef struct _Node {
Node node;
} Node;
I've done some research and tried using pointers, ...
-2
votes
2answers
32 views
Recursive function divide a number
I need to create a recursive function that receives a number by two without using /.
This is what I wrote, but it works only if after dividing it will still be a decimal number and not a float, ...
4
votes
0answers
27 views
what is has_zero and find_zero in word_at_a_time.h used for
In linux kernel, inlucde/linux/word_at_a_time.h, there are two functions:
static inline long find_zero(unsigned long mask)
{
long byte = 0;
#ifdef CONFIG_64BIT
if (mask >> 32)
...
1
vote
0answers
17 views
TerminateThread() returns error when terminating the thread
I have a ThreadA created using the CreateThread function. Inside ThreadA, another thread, ThreadB is created using the CreateThread function.
Now, I want to terminate ThreadB from ThreadA but the ...
0
votes
0answers
10 views
Libraries for parallel distributed cholesky decomposition in c/c++ in mpi environment?
What libraries are available for parallel distributed cholesky decomposition in c/c++ in mpi environment?
I've found the scalapack library, and this might be the solution I'm looking for. It seems ...
0
votes
1answer
47 views
Writing Structs to a file in c [closed]
Is it possible to write an entire struct to a file
example:
struct date {
char day[80];
int month;
int year;
}
-3
votes
0answers
43 views
Complex number program in C [closed]
This program takes two complex numbers and sums the two numbers and prints result. But during negative numbers it's not
#include<stdio.h>
typedef struct{
float real;
float imag;
} ...
0
votes
2answers
67 views
Function printing wrong value, but is calculating the correct value
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float ts (int a) {
float tp;
tp=a*60;
return tp;
}
int ponto (float t) {
if (t < 180)
return 100;
...
-1
votes
0answers
42 views
Variable-size parameters to function
I want to send an arbitrarily sized argument to a C function.
Right now I'm doing: (A contrived example)
typedef struct {
int a;
float b;
} myStruct;
void foo(int, char)
void bar(int, myStruct)
...
-1
votes
0answers
24 views
effect of sleep(1) after pthread_join()?
I have a question.
Why use sleep(1) function after pthread_join() ??
Pthread_join alone is not enough??
I have tried using pthread join without sleep() in some open source code but it resulted in ...
-1
votes
1answer
24 views
Can't find reference of hash in qstr structure
As you can see in http://lxr.linux.no/#linux+v3.9.5/fs/namei.c#L1751
for(;;) {
struct qstr this;
long len;
int type;
err = may_lookup(nd);
...
1
vote
4answers
110 views
“Arrays = Pointers” *mind blown*. Many years later: “Actually, they don't” *mind blown again* [closed]
Context:
I programmed in C on and off for about 2 years before discovering that a[i] is just syntax sugar for *(a + i) and was therefore equivalent to *(i + a) and i[a]. My reality was turned upside ...