Category "pointers"

C code collecting info through a function and passing it back, of datatype struct

//Program is to collect input from user so that can pass the array of inputs from the user to another print function but that are quite some Errors in the code

Create a linked list with the characters of a string-C90

The problem : I am trying to create a linked list which contains the characters of a string in each field of the linked list(to get the distance of each letter

How to delete a heap allocated std:::array

I have this pointer in a class: std::array<std::array<std::array<Item*, XSize>, YSize>, ZSize>* Items; In the constructor: Items = new std::a

Length of array in function argument

This is well known code to compute array length in C: sizeof(array)/sizeof(type) But I can't seem to find out the length of the array passed as an argument t

C pointer to a pointer confusion

I have the following code. I tried to change the value of y by using a pointer to a pointer (i.e. trying to do a de-referencing twice from the pointer that poin

How do I convert a number to a string without using stdlib.h or string.h?

Here is my exercise: Write a function that receives from the user two strings that show two real numbers (possibly negative), And produces a string that contai

Pointers - Strings

I have a code chunk which is quite meaningless for me. Is there someone can explain it to me? Thanks int strLength(char *str) { char *p = str; // Go until the e

I'm having a problem creating a linked list [duplicate]

#include<stdio.h> #include<stdlib.h> void insert_front(struct node* head, int block_number); void insert_rear(struct node* head,

Recomended formating for temporarily inverting data at pointer and then passing pointer to temporarily inverted data

Long story short, I have a pointer to a value that is stored inverted, so when we are calculating a hash to verify data integrety, we need to invert the data th

In plain C, could we implement generic functions using pointers to char instead of pointers to void?

In plain C, pointers to void are useful as arguments to generic functions, such as a generic quicksort, or a generic swap, etc., as seen here: Implementation of

Why are function pointers and data pointers incompatible in C/C++?

I have read that converting a function pointer to a data pointer and vice versa works on most platforms but is not guaranteed to work. Why is this the case? Sho

Cannot restart typedef'd 2D array whose address is saved in struct

I have this typedef and struct: typedef double mat[MAT_SIZE][MAT_SIZE]; typedef struct matList { char *name; mat *matrix; } matList; and I create an a

Why macros and functions work differently about same code in c

I am new to programing, and I found one interesting but difficult to find reason problem, so I am writing this post. I was trying to write swap function: When I

How to avoid poorly optimized code for Fortran array pointers?

I get rather poorly optimized assembly with gfortran 11.2 when using array pointers, even in seemingly very simple cases. For example, the optimized code (https

With arrays, why is it the case that a[5] == 5[a]?

As Joel points out in Stack Overflow podcast #34, in C Programming Language (aka: K & R), there is mention of this property of arrays in C: a[5] == 5[a] Jo

Understanding Scope / Copy in Python Classes where arguments default to numpy vectors

I have a pretty simple python-3 code that is puzzling me. test.py : import numpy as np class PARTICLE: def __init__(self, PosV = np.zeros(3), Mass=0):

Does `offsetof(struct Derived, super.x) == offsetof(struct Base, x)` hold true in C?

I am unsure what André Caron means here: Virtual functions in C ... some of this code relies on (officially) non-standard behavior that "just happens" t

C++ How to create a constant pointer to a function?

I want to have a class with a constant pointer to a function as a member. However, I'm instead creating functions with constant return values (a strange feature

cannot convert 'LinkedList::filter(void (*)(Node*))::<lambda(Node*)>' to 'void (*)(Node*)'

Im trying to implement a simple LinkedList class, but this error shows up and I don't understand why. struct Node { public: int val; Node* next; Nod

stack smashing detected when trying to get to typedef two dinatial array that the adress store inside struct

i have this typedef of two dinantial array, and strust the keep his adress typedef double mat[MAT_SIZE][MAT_SIZE]; typedef struct matList { char *name;