我需要存储在uint8_t
指针确定数组的位置。
示例:
uint8_t array[40] = {1,2,3,etc...}
uint8_t *pointer = array[5] - [25]
。保存指针只在5到25之间的位置。我需要用C ++语言。
感谢社区!
答案 0 :(得分:1)
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container pt-5">
<div class="row">
<div class="col-8" id="main">
<div class="media d-block">
<div class="media-body">
<h5 class="mt-0">Media heading</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
<pre class="code" style="background: #f1f1f1;"><code class="php"><span style="color: #0275d8; font-weight: bold;">if</span><span style="color: #A67f59;">(</span> <span style="color: #04527F;">$line_numbers</span> <span style="color: #A67f59;">&&</span> <span style="color: #04527F;">$line_numbers</span> <span style="color: #A67f59;">!==</span> <span style="color: #707070;">'false'</span> <span style="color: #A67f59;">)</span> <span style="color: #A67f59;">{</span>
<span style="color: #04527F;">$output</span> <span style="color: #A67f59;">.=</span> <span style="color: #707070;">'<div class="line_numbers">'</span><span style="color: #A67f59;">;</span>
<span style="color: #04527F;">$line_count</span> <span style="color: #A67f59;">=</span> <span style="color: #0275d8; font-weight: bold;">substr_count</span><span style="color: #A67f59;">(</span> <span style="color: #04527F;">$code</span><span style="color: #A67f59;">,</span> <span style="color: #707070;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span> <span style="color: #A67f59;">)</span><span style="color: #A67f59;">;</span>
<span style="color: #04527F;">$line_start</span> <span style="color: #A67f59;">=</span> <span style="color: #A67f59;">(</span> <span style="color: #0275d8; font-weight: bold;">is_numeric</span><span style="color: #A67f59;">(</span> <span style="color: #04527F;">$line_numbers</span> <span style="color: #A67f59;">)</span> ? <span style="color: #04527F;">$line_numbers</span> <span style="color: #A67f59;">:</span> <span style="color: #70B9EF;">1</span> <span style="color: #A67f59;">)</span><span style="color: #A67f59;">;</span>
<span style="color: #0275d8; font-weight: bold;">for</span><span style="color: #A67f59;">(</span> <span style="color: #04527F;">$i</span> <span style="color: #A67f59;">=</span> <span style="color: #70B9EF;">0</span><span style="color: #A67f59;">;</span> <span style="color: #04527F;">$i</span> <span style="color: #A67f59;"><=</span> <span style="color: #04527F;">$line_count</span><span style="color: #A67f59;">;</span> <span style="color: #04527F;">$i</span><span style="color: #A67f59;">++</span> <span style="color: #A67f59;">)</span> <span style="color: #A67f59;">{</span>
<span style="color: #0275d8; font-weight: bold;">if</span><span style="color: #A67f59;">(</span> is_tax<span style="color: #A67f59;">(</span> <span style="color: #707070;">'files'</span> <span style="color: #A67f59;">)</span> <span style="color: #A67f59;">)</span>
<span style="color: #A67f59;">{</span>
<span style="color: #04527F;">$output</span> <span style="color: #A67f59;">.=</span> <span style="color: #707070;">'<span id="L'</span> <span style="color: #A67f59;">.</span> <span style="color: #0275d8; font-weight: bold;">sprintf</span><span style="color: #A67f59;">(</span><span style="color: #707070;">"<span style="color: #009933; font-weight: bold;">%02d</span>"</span><span style="color: #A67f59;">,</span> <span style="color: #04527F;">$i</span> <span style="color: #A67f59;">+</span> <span style="color: #70B9EF;">1</span> <span style="color: #A67f59;">)</span> <span style="color: #A67f59;">.</span> <span style="color: #707070;">'">'</span> <span style="color: #A67f59;">.</span> <span style="color: #A67f59;">(</span> <span style="color: #04527F;">$line_start</span> <span style="color: #A67f59;">+</span> <span style="color: #04527F;">$i</span> <span style="color: #A67f59;">)</span> <span style="color: #A67f59;">.</span> <span style="color: #707070;">"</span><span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #A67f59;">;</span>
<span style="color: #A67f59;">}</span>
<span style="color: #0275d8; font-weight: bold;">else</span>
<span style="color: #A67f59;">{</span>
<span style="color: #04527F;">$output</span> <span style="color: #A67f59;">.=</span> <span style="color: #A67f59;">(</span> <span style="color: #04527F;">$line_start</span> <span style="color: #A67f59;">+</span> <span style="color: #04527F;">$i</span> <span style="color: #A67f59;">)</span> <span style="color: #A67f59;">.</span> <span style="color: #707070;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #A67f59;">;</span>
<span style="color: #A67f59;">}</span>
<span style="color: #A67f59;">}</span>
<span style="color: #04527F;">$output</span> <span style="color: #A67f59;">.=</span> <span style="color: #707070;">'</div>'</span><span style="color: #A67f59;">;</span>
<span style="color: #A67f59;">}</span></code></pre>
</div>
</div>
</div>
<div class="col-4 bg-warning">sidebar</div>
</div>
</div>