TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Everything you need to know about pointers in C (2010)

26 点作者 ank_the_elder超过 4 年前

5 条评论

slmjkdbtl超过 4 年前
The time [0] I found out about ptr_b in<p><pre><code> int* ptr_a, ptr_b; </code></pre> isn&#x27;t actually initialized as a pointer I changed all my C code to marking * before the variable name, fun times. It&#x27;s helpful to think int as the base type and * the indicator of functionality like [] and ().<p>Also just found out the author was the developer of Adium [1], which is one of my favorite softwares (best logo) on macOS.<p>[0] <a href="http:&#x2F;&#x2F;c-faq.com&#x2F;decl&#x2F;charstarws.html" rel="nofollow">http:&#x2F;&#x2F;c-faq.com&#x2F;decl&#x2F;charstarws.html</a><p>[1] <a href="https:&#x2F;&#x2F;adium.im&#x2F;" rel="nofollow">https:&#x2F;&#x2F;adium.im&#x2F;</a>
评论 #24480216 未加载
评论 #24481206 未加载
jwilk超过 4 年前
&gt; void pointers are incremented or decremented by 1 byte.<p>No, void pointer arithmetic is not allowed by the C standard: <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;3523145&#x2F;pointer-arithmetic-for-void-pointer-in-c#3524270" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;3523145&#x2F;pointer-arithmet...</a>
评论 #24479747 未加载
评论 #24479673 未加载
weltensturm超过 4 年前
By C half-assedly trying to make &quot;* &quot; part of the name, just so you can use &quot;* ptr&quot; everywhere like it is an actual variable name, you get confusions such as this.<p>First &quot;foo_ptr&#x27;s type is int * &quot;, but then &quot;The pointer has a type, too, by the way. Its type is int.&quot;.<p>I also refuse to agree with &quot;An int * * &#x27;s type is int * &quot;. :)<p>But I guess &quot;the type of `* ptr` is int, the type of `ptr` is int * &quot; would be even more confusing.
评论 #24479875 未加载
0x6862超过 4 年前
int array[] = {...}<p>1[array] == array[1]<p>Now add in some poorly named variables for some real fun<p><a href="https:&#x2F;&#x2F;github.com&#x2F;Droogans&#x2F;unmaintainable-code#cs-eccentric-view-of-arrays" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Droogans&#x2F;unmaintainable-code#cs-eccentric...</a>
ChrisSD超过 4 年前
&gt; A pointer is a memory address.<p>This is an amazingly wrong statement. In assembly you deal with memory addresses. Pointers in C are a much higher level abstraction.<p>&gt; On current mainstream Intel processors, it occupies four bytes of memory (because an int is four bytes wide).<p>This depends on the compiler as well as the processor.
评论 #24479590 未加载
评论 #24479851 未加载
评论 #24480187 未加载
评论 #24479531 未加载