小编Has*_*tar的帖子

指向2D数组的指针C,C++

我正在学习指针:

int x[10]; 
int *p = &x
Run Code Online (Sandbox Code Playgroud)

这将使指针类型int成为第一个元素.所以,如果我有2D数组,我需要使用双指针:第一个指针指向数组的第二个维度.这意味着 :

int x[3][4] = {{1,2,3,4},{5,6,7,8},{9,9,9,9}};
Run Code Online (Sandbox Code Playgroud)

当我想指出它时,我必须像这样声明第二维的大小,对吧?

int *p[4] = x;
Run Code Online (Sandbox Code Playgroud)

或者存在通过键入另一种方式:int **p; ?

int *p[4]是整数指针这需要的阵列4 * (sizeof(int*)),是吗?

c c++ arrays pointers multidimensional-array

6
推荐指数
1
解决办法
3445
查看次数

在ISR结束时使用reti()

我有这个代码不起作用的问题.. ISR正在工作..我在其他代码中测试了它的闪烁..

但是要将x ++放在ISR中并在main()函数中读取X,它永远不会闪烁...

我不熟悉asm我认为这是编译器optomization所以我把变量挥发,但它没有工作..

#define F_CPU 16000000UL

#include <avr/interrupt.h>
#include <avr/io.h>
#include <util/delay.h>

volatile static uint8_t x = 1;

ISR( TIMER0_OVF_vect )
{
    x++;
    reti();
}

int main(void)
{

    /* Replace with your application code */
    DDRB = DDRB | 0B00100000 ; // pinMode(13,OUTPUT);
    TCCR0A = 0;
    TCCR0B = (1 << CS00 ) | (1 << CS02 ); //1024 prescaler
    TIMSK0 |= 1 << TOIE0 ;
    sei();

    while (1) 
    {

        if (x  >= 61) //never happens ? 
        {
            PORTB …
Run Code Online (Sandbox Code Playgroud)

c microcontroller avr isr atmelstudio

1
推荐指数
1
解决办法
431
查看次数

Laravel 公共 CSS 样式表

我正在使用此代码来包含我的公共样式表:

<!DOCTYPE html>
<html>
    <head>
        <title>Laravel</title>
        <link rel="stylesheet" href="{{ asset('css/c_bootstrap.css') }}">
        <link rel="stylesheet" href="{{ asset('css/style_x.css') }}"  />
        <link rel="stylesheet" href="{{ asset('css/sb-admin.css') }}" />
    </head>
    <body>
        <!-- navbar -->
        @include ('layout.navbar')

        <div class="container">
            <div class="content">
            	@yield('content')
            </div>
        </div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

在查看页面源码中: 在此处输入图片说明

当我点击它时,我得到了这个: 在此处输入图片说明

所以它看起来真的很有效。然而,这只是来自 Laravel 错误页面的错误 CSS: 在此处输入图片说明

那么我在这里做的错误是什么?

我的文件夹:

|- public
|-|--- assets
|-|---|--- css
|-|---|---|--- c_bootstrap.css
|-|---|---|--- s.css
|-|---|---|--- sb-admin.css
Run Code Online (Sandbox Code Playgroud)

html css laravel laravel-blade

0
推荐指数
1
解决办法
3517
查看次数

将int8转换为int7的最快方法

我有一个功能,int8_t val将其转换为int7_t.

//Bit [7] reserved
//Bits [6:0] = signed -64 to +63 offset value
// user who calls this function will use it correctly (-64 to +63)
uint8_t func_int7_t(int8_t val){
    uint8_t val_6 = val & 0b01111111;
    if (val & 0x80)
        val_6 |= 0x40;
    //...
    //do stuff...
    return val_6;
}
Run Code Online (Sandbox Code Playgroud)

操作int8到int7 的最佳和最快方法是什么?我有效率和快速地做到了吗?还是有更好的方法?

如果重要的话,目标是ARM Cortex M0 +

更新:

在阅读了不同的答案后,我可以说这个问题被错误了?(或者我在问题中的代码是对其他人做出错误假设的原因)我有意向int7做int8

所以它将通过无所事事来完成,因为

8位:

 63 = 0011 1111
 62 = 0011 1110
  0 = 0000 0000
 -1 = 1111 …
Run Code Online (Sandbox Code Playgroud)

c c++ performance bit-manipulation

-3
推荐指数
1
解决办法
207
查看次数