All Questions
1,474
questions
-1
votes
2
answers
88
views
uint8_t elements exceeding one byte?
I saw this code:
uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
I know uint8_t holds a byte, so how does this line of code work when a single
element, 0xFF, is in itself one whole ...
1
vote
3
answers
101
views
In C, why can a variable holding a char array be assigned to a pointer, but the address of the same pointer cannot?
Consider the following code:
char stringy[] = "There's too much confusion, I can't get no relief!";
char *pStringy;
pStringy = stringy;
This compiles -
stringy is an array of characters, ...
1
vote
2
answers
101
views
Why does the int type change size based on processor architecture while other types do not?
I am studying coding conventions and came across a rule that advises against using the int type. I believe this stems from the characteristic of the int type, which dynamically changes its size based ...
0
votes
2
answers
64
views
Defining macro and using data types to find an absolute value
I'm trying to solve this problem from my textbook in the Preprocessor section.
The problem asks to define a macro ABSOLUTE(num) to calculate an absolute value of some number or arithmetic expression.
...
4
votes
1
answer
81
views
Clarification of "The meaning of a value is determined by the type of the expression used to access it"
From §6.2.5(1) of the standard:
The meaning of a value stored in an object or returned by a function is determined by the type of the expression used to access it. (An identifier declared to be an ...
-1
votes
1
answer
63
views
value divided by 100 does not return a decimal place although both the divident and the divisor are declared as data type float in c languages [closed]
I am about to solve the readability task from the CS50 course. This should become a programm that counts letters and words to use them in the Coleman-Liau -Index. Therefore i would like to divide the ...
1
vote
1
answer
65
views
Undefined behavior with unions
While working with 3D points, I came across this approach to type definition :
union point_3d {
struct {
GLdouble x, y, z;
} coord;
GLdouble tab[ 3 ];
};
Thus, the coordinates ...
3
votes
1
answer
174
views
PHP FFI - Convert PHP array to C pointers array
I have a C function with the following signature. It accepts (from my humble C understanding) an array of C strings and returns a pointer to a random string.
const char *get_random(const char *const *...
0
votes
1
answer
67
views
I want a warning if I try to add an "index" to a "size"
I undertook a small exercise, to use dedicated types for different things in my software, instead of everything being (e.g.) uint64_t.
For example:
typedef uint64_t tIDX;
typedef uint64_t tSIZE;
...
0
votes
2
answers
96
views
Why is void classified differently from other basic types? [closed]
On cppreference.com they classify types as:
Void types
Basic types
Enumerated types
Derived types
I cannot find the reason why they have classified void as a fundamental type. It implies that there ...
0
votes
2
answers
66
views
Return two dimension array from function in C
I input a matrix into a function and I want to output the multiplication of it by itself. I can't manage to return the result in the correct format.
int **multiplyMatrix(int matrixA[10][10], int ...
5
votes
1
answer
134
views
Forward Declaration of Function Type in C
I want to declare a recursive function type (a function which declares itself) in C.
In a language like Go I can do:
type F func() F
func foo() F {
return foo
}
If I try to do the equivalent in C:
...
3
votes
3
answers
72
views
Why can't I just add an int to a memory address to address any array?
I am trying to override part of my first string with my second one with an offset of 2.
Here is my second attempt that works:
#include <stdio.h>
#include <string.h>
int main() {
char s[...
1
vote
1
answer
116
views
How can I handle user input for a double array in C, allowing both int and float values while ensuring they fall within specified constraints?
Question is to take elements of a (2D) array from the user, but the elements can be of either int or float datatype. These are the following constraints:
Element Values:
Integers: -2147483648 to ...
-2
votes
1
answer
157
views
OpenGL requires a "const char", but I have to read it from file
I'm creating a C header to load my shaders from a file, instead of how I was doing before, that was something like this:
const char *vertexShaderSource = "#version 330 core\n"
"...