小编use*_*534的帖子

mips打印字符

li $a0, '0'
li $v0, 11
syscall
Run Code Online (Sandbox Code Playgroud)

所以我有这个代码来打印$ a0中的内容

在打印字符方面,-1和1之间有什么区别?当我尝试打印-1而不是0时,火星只是抱怨价值.

是否有任何数学函数来处理正数的负数?

mips

5
推荐指数
1
解决办法
3万
查看次数

计算无符号整数中的位数

我想编写一个bitCount()在文件中命名的函数:bitcount.c它返回其无符号整数参数的二进制表示中的位数.

这是我到目前为止:

#include <stdio.h>

int bitCount (unsigned int n);

int main () {
    printf ("# 1-bits in base 2 representation of %u = %d, should be 0\n",
        0, bitCount (0));
    printf ("# 1-bits in base 2 representation of %u = %d, should be 1\n",
        1, bitCount (1));
    printf ("# 1-bits in base 2 representation of %u = %d, should be 16\n",
        2863311530u, bitCount (2863311530u));
    printf ("# 1-bits in base 2 representation of %u = %d, should …
Run Code Online (Sandbox Code Playgroud)

c binary bit-manipulation

2
推荐指数
3
解决办法
2万
查看次数

内存管理c

所以我知道mallocs适用于堆而不是堆栈.

我有几个问题:

是否分配或释放了这些代码?

我没有看到任何自由语句,所以我假设没有任何东西被释放,所以内存泄漏是正确的?

只是为了好奇,如果我试图释放ptr,它会崩溃.如果我尝试释放它,它工作正常.

  int num;
        int *ptr;
        int **handle;

        num = 14;
        ptr = (int *)malloc(2 * sizeof(int));
        handle = &ptr;
        *ptr = num;
        ptr = &num;
        handle = (int **)malloc(1 * sizeof(int **));
Run Code Online (Sandbox Code Playgroud)

c free

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

标签 统计

c ×2

binary ×1

bit-manipulation ×1

free ×1

mips ×1