Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
-2 votes
1 answer
146 views

Visual studio throwing an error when I name my class "floor" [duplicate]

Ok so I was messing around with some OOPs in visual studio 2022 community edition in C++, when I came across such a baffling problem that I don't even know where to start searching for it. #include &...
7 votes
6 answers
2k views

C program: Use an array outside the scope it was defined in

I have some code in which an array of strings is defined in a conditional statement. The array is out of scope where I need it. So I defined another pointer in the outer scope. In the conditional ...
0 votes
0 answers
81 views

How to properly allocate dynamic memory for matrix operations in C [duplicate]

I am trying to learn C, and I want to specifically work with arrays and matrices as I do scientific simulations (coming from python!!). After writing few basic 1-D array codes in C, I am going for ...
2 votes
2 answers
96 views

Pointers, referencing, and dereferencing static strings in assembly language

I'm writing a little toy program to try to help myself better understand this language (AT&T syntax, x86_64 assembly language). Consider this code, if you'll be so kind: .section .data mystring: ....
2 votes
4 answers
206 views

Two pointers referencing the same memory location, possible to make null if we deallocate the space?

If two pointers are referencing the same memory location. Will it be possible to make one pointer null, if we deallocate that memory location? For example: #include <iostream> using namespace ...
1 vote
1 answer
243 views

Using an asterisk as prefix or suffix for working with pointers

During a job interview, I was asked a question about the differences between **a, *a, a, a* and a** (which I failed). I just asked ChatGPT about the difference between *a and a* and it came up with ...
Dominique's user avatar
  • 17.5k
0 votes
0 answers
67 views

how can i get a digit from integer by pointers arithmetic? [closed]

I'm trying to implement Radix Sort with Counting Sort, I have already Implemented Counting sort of ints array. I had an idea to use Counting sort in Radix implementation this way: Get the specific ...
5 votes
2 answers
198 views

How to free the value inside struct in c

I don't know how to reset the value field inside the Hello struct. It's a pointer pointed to an outside passed input argument. typedef struct Hello { void *value; } Hello; Hello* create_hello() { ...
-2 votes
3 answers
191 views

Can I declare a variable along with a pointer?

Can I declare a variable along with a pointer? //like this struct node n1,n2,n3,*start; //or do i have to do it separately struct node *start;struct node n1,n2,n3; to declare variable alongside ...
4 votes
1 answer
124 views

Why don’t pointers appear in Python Tutor’s memory visualization in C?

I’m new to C and I’m trying to understand how pointers work. In this piece of code, when I run it on Python Tutor (pythontutor.com) to see how the stack and heap work, I never see the pointer being ...
Bilal's user avatar
  • 173
5 votes
3 answers
306 views

The C 'Array-to-Pointer Decay' Paradox: Why do these function declarations behave identically? void func(char a[10]) vs void func(char *a)

I'm struggling to understand a core concept in C regarding Array-to-Pointer Decay when arrays are passed as function parameters. It is well-known that when an array is passed to a function, it "...
0 votes
0 answers
138 views

Does accessing the contents of the string after calling reserve causes UB? [duplicate]

From another thread I found that indeed allocates enough storage to hold at least n elements, but it doesn't actually fill the container with any elements If elements are already allocated why ...
6 votes
1 answer
155 views

Is pointer arithmetic on a pointer that points to a destroyed array element well-defined?

In Cppreference the rules for pointer arithmetic include: If P points to the i-th element of an array object x with n elements, given the value of J as j, P is added or subtracted as follows: – P + J ...
0 votes
1 answer
162 views

How to release dynamic memory on the heap in called function C++

#include <iostream> using namespace std; int* apply_all(int* arr1, int size1, int* arr2, int size2){ int* on_the_heap = new int(size1 * size2); int temp = 0; for(int i {0}...
Adepa's user avatar
  • 19
0 votes
6 answers
261 views

Pointer to an array in a struct in C

I'm working (in C) with a struct that contains arrays of strings. How do I point to one of those strings? To make it a bit clearer, consider: struct Books { char title[MAX1][MAX2]; char author[MAX1][...

15 30 50 per page
1
2 3 4 5
...
3822

AltStyle によって変換されたページ (->オリジナル) /