Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read
Q&A

Posts tagged pointers

2 child tags

Use for questions dealing with a data type that "points to" another value stored in memory. DO NOT use when talking about references from managed languages. Also, indicate the actual programming language used (e.g. C, C++).

This tag doesn't have a detailed wiki yet.

81%
+7 −0
Q&A Is there any benefit to using new?

I've heard that in modern C++, smart pointers are preferred to raw pointers for ownership (the so-called RAII principle, as I understand it). This makes sense, and since then I've always used them...

1 answer  ·  posted 3mo ago by Moshi‭  ·  last activity 3mo ago by InfiniteDissent‭

40%
+2 −4
Q&A Problems with data structures and filestreams.

So I just started learning how to use file-streams in C &amp; decided to attempt a question which is to do with library management in C, however I am currently encountering some problems and feel l...

2 answers  ·  posted 12mo ago by dumplings‭  ·  edited 5mo ago by Alexei‭

80%
+6 −0
Q&A array of arrays vs array of pointers to store array of string literals

Let's consider the following code: const char a[][4] = {"aa", "aaa"}; const char *b[] = {"bb", "bbb"}; const char *const c[] = {"cc", "ccc"}; For shared libraries, both b and c arrays require...

0 answers  ·  posted 6mo ago by alx‭  ·  edited 6mo ago by alx‭

86%
+11 −0
Q&A Should I check if pointer parameters are null pointers?

When writing any form of custom function such as this: void func (int* a, int* b) Should I add code to check if a and b are null pointers or not? if(a == NULL) /* error handling */ When po...

4 answers  ·  posted 8mo ago by Lundin‭  ·  last activity 8mo ago by Dirk Herrmann‭

70%
+5 −1
Q&A What does a variable followed by parentheses ("ptr()") mean?

What does ptr() mean in this code? #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; void PrintHello() { printf("Hello\n"); } int Add(int a, int b) { return a+b; } int main...

2 answers  ·  posted 12mo ago by dumplings‭  ·  last activity 8mo ago by Martin Bonner‭

Question c pointers
80%
+6 −0
Q&A Is it OK to use scanf with a void pointer?

I've created a function that calls scanf passing a void pointer as argument: void read(const char *format, void *p) { scanf(format, p); } And tested it with different types: int n; read...

2 answers  ·  posted 10mo ago by hkotsubo‭  ·  last activity 9mo ago by Lundin‭

Question c pointers scanf
80%
+6 −0
Q&A When does it not work to dereference the pointer for sizeof during malloc?

Background This is kind of a subquestion to How to properly use malloc? When allocating, there are basically two common ways of using the sizeof operator: int *p; p = malloc(n * sizeof *p); /...

1 answer  ·  posted 10mo ago by klutt‭  ·  edited 10mo ago by hkotsubo‭

Question c pointers malloc
80%
+6 −0
Q&A Are static pointers implicitly initialized to NULL?

Consider this code: #include &lt;stdio.h&gt; int main(void) { static void *ptr; if(ptr == NULL) puts("It's NULL!"); } I wonder if this is guaranteed to print "It's NULL!" I know ...

1 answer  ·  posted 10mo ago by klutt‭  ·  last activity 10mo ago by Lundin‭

83%
+8 −0
Q&A Are there references in C?

When reading posts at programming sites such as this one, I frequently encounter people saying things like: "There is no pass-by-reference in C, everything is passed by value." People claiming su...

4 answers  ·  posted 10mo ago by Lundin‭  ·  last activity 10mo ago by klutt‭

60%
+4 −2
Q&A Question regarding an error message in my compiler to do with my code on linked list.

Can anyone help me, I'm currently learning pointers, this is the code I wrote to try and insert a node at the beginning of the list. However at the part where I included the comment of "error at th...

1 answer  ·  posted 11mo ago by hamburgersarecool‭  ·  edited 11mo ago by hamburgersarecool‭

25%
+0 −4
Q&A What does the greater than 0 indicate in the case of this statement 'if (compare(A[j], A[j+1]) > 0)' ? Thank you.

Question: There is a list of integers in an array (3,2,1,5,6,4), sort this list in both ASCENDING &amp; DESCENDING order. Create a sort function. #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; ...

1 answer  ·  posted 12mo ago by dumplings‭  ·  last activity 12mo ago by Lundin‭

66%
+4 −1
Q&A Invalid memory access when trying to dereference a pointer obtained through a function call

Hey, regarding a question on returning pointers as functions, why does my code produce this error &amp; won't print out the sum = 6? #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; int *A...

1 answer  ·  posted 12mo ago by dumplings‭  ·  last activity 12mo ago by celtschk‭

71%
+3 −0
Q&A Why use an asterisk after a type?

#include&lt;stdio.h&gt; struct Node{ int data; struct Node* next; }; Here I used an asterisk after Node. What is it used for? What if I don't put any asterisk after Node (both Node...

2 answers  ·  posted 1y ago by deleted user  ·  edited 1y ago by hkotsubo‭

Question c pointers
80%
+6 −0
Q&A Is it undefined behaviour to just make a pointer point outside boundaries of an array without dereferencing it?

I have heard that it is undefined behaviour to make a pointer point outside boundaries of an array even without dereferencing it. Can that really be true? Consider this code: int main(void) { ...

2 answers  ·  posted 2y ago by klutt‭  ·  last activity 2y ago by hkotsubo‭

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!

Like what we're doing? Support us! Donate