Skip to main content
Filter by
Sorted by
Tagged with
2 votes
2 answers
74 views

I'm writing some C code where I want to have a NULL-terminated GPtrArray containing static strings. Typically, I would use g_ptr_array_new_null_terminated () to construct a NULL-terminated GPtrArray, ...
Newbyte's user avatar
  • 3,957
1 vote
1 answer
110 views

I'm just wondering if there is a way I can tell the compiler that I want to create a static array inside the .data section of the Arduino's SRAM, where the array's size is calculated using the size of ...
Logan Seeley's user avatar
0 votes
2 answers
94 views

Task: Implement a function in standard C that constructs a jagged array J from a linear array W. You must adhere to the following specifications and constraints: Input: The function takes a ...
Nightworks1928's user avatar
1 vote
1 answer
105 views

Consider this case: Using macos leaks -atExit -- have this code: #include <stdlib.h> int main(void) { char *leak = malloc(100); return (0); } that is naturally a leak...which "...
Lineath's user avatar
  • 43
0 votes
1 answer
217 views

I'm trying to change a dynamic memory object to static memory use to hopefully free up memory in a way. Original code(dynamic): Class.h: Class() { auto output = std::unique_ptr<uint8_t[]>(new ...
bilumer's user avatar
1 vote
1 answer
75 views

cf. Environment: Microsoft Visual Studio 2022 17.5 // main.c int main() { int a = 0x12345, b = 0x67890; int arr[5] = { 0x1234, 0x2345, 0x3456, 0x4567, 0x5678 }; return 0; } If I execute ...
minseo's user avatar
  • 13
0 votes
1 answer
141 views

Here is my code: template<typename T, std::size_t N> class my_array { public: const T& at(std::size_t index) const { if(index>N) throw std::...
Andrew's user avatar
  • 65
1 vote
1 answer
115 views

I am working on a program in C that processes an array of character pointers. I have several functions that operate on this array, including longest_name(), unique(), and others. When I call the ...
Aman Pachouri's user avatar
0 votes
1 answer
563 views

I would like to declare a vector in the .bss segment, but I am not sure how to do so. I would like the vector to have 30000 bytes. I have tried to compile some C code into assembly, but I don't quite ...
Sorinacheul 1's user avatar
-2 votes
3 answers
987 views

As i know from c/c++ and general knowledge of data structures, arrays are structured as sequential memory blocks with constant size. So if I create an array of five i32 variables then array size bill ...
Ufuk Ilke Avci's user avatar
-1 votes
2 answers
119 views

I wrote a code for entering element and displaying the array at the same time. The code works but since char A[4] is static memory why does not it terminate/throw error after entering more than four ...
Kushaal2528's user avatar
-2 votes
2 answers
773 views

I am trying to get the bytes and pointers and how they are stored can any one explain or answer some of my questions. Thank you int num = 513; <-- allocating a 4 bit memory by initializing //[01][...
user avatar
1 vote
1 answer
74 views

In tree, while taking input (inside takeInput function), tree node was made using dynamic allocation, but I tried doing it statically, but as tree node were declared inside a function locally it ...
Suryansh Singh's user avatar
0 votes
0 answers
50 views

I am new to C++ programing, I learnt that all the static variables are allocated at compile time on stack memory, so their size should be known before compiling by the compiler. But the dynamic ...
Kaneki's user avatar
  • 105
-1 votes
1 answer
233 views

Is there functionality, in C++, to detect whether the target of a pointer has been allocated from dynamic memory or is living in static memory (including global memory)? In the example below, I'd like ...
Thomas Matthews's user avatar
-1 votes
1 answer
146 views

I am creating a mathematical data structure in c++20 (Mingw-w64 clion) which i can partially offload from memory to storage and vice versa, Due to its capacity and size. While learning how i could ...
D. Sikilai's user avatar
0 votes
1 answer
3k views

I started working through the book Hands-On System Programming in C++ and I tried to create the following linked list with a template without dynamic memory allocation. But every time I try to build ...
Ingo Mi's user avatar
  • 1,109
3 votes
1 answer
181 views

I'm really stuck on this one. ex17 is supposed to be teaching me heap and stack memory allocation by providing a simple database (my questions are specific, but i'll leave it there just in case you ...
Georgy Martynovich's user avatar
1 vote
1 answer
857 views

What is the difference between defining an array of a length that is definied before runtime (depends on command line arguments) with array[size] and using malloc()? array[i] leads to the data put on ...
Nivatius's user avatar
  • 270
1 vote
1 answer
2k views

I have an array that contains bytes of information (a payload), but I want to use this array in two functions. How can I return it? I don't know if I have to declare it different or in other place. ...
Lleims's user avatar
  • 1,373
0 votes
1 answer
649 views

Context: I'm working on a project where a client needs us to use custom dynamic memory allocation instead of allocating objects from the stack. Note that the objects in question have size known during ...
user avatar
2 votes
1 answer
676 views

The static keyword keeps the pointer alive until the program terminates, but is the memory allocated to the pointer buffer free'd automatically when the process terminates? or does the programmer have ...
AymenTM's user avatar
  • 579
1 vote
1 answer
606 views

I have been experimenting with sound using C. I have found a piece of code that would allow me to generate PCM wave sound and output it through the sound card. It worked pretty well for what it was. ...
PlagueTR's user avatar
0 votes
0 answers
80 views

This problem has been bugging me for quite a while now. int n; cin>>n; if(n is even) { char c; cout<<"character created"; } else { double d; cout<<"double created"; } now if the ...
Ceb's user avatar
  • 3
1 vote
1 answer
390 views

Virtual destructors are needed when an object is (potentially) destructed from a base class pointer. Consider a program without dynamic memory as often found in embedded systems. Here, using new or ...
Alexander's user avatar
  • 1,108