小编sob*_*bha的帖子

错误:一元'*'的类型参数无效(具有'long int')

这是我编写的一个小程序,用于打印存储在内存位置(0x7fffdf222fec)的值。 error as 4:20: error: invalid type argument of unary ‘*’ (have ‘long int’ printf("\n %p ",*(0x7fffdf222fec));

我在Ubuntu 16.04中使用gcc编译器,我的ram是4 GB。我不能使用这种方式在此位置访问值吗?

#include<stdio.h>
void main(){
    printf("\n  %p   ",*(0x7ffeae3b3674));
}
Run Code Online (Sandbox Code Playgroud)

预期结果是存储在地址中的垃圾值

我写了一个这样的程序,得到了as的地址

#include<stdio.h>
void main(){
    int a;
    printf("%p",&a);
}
Run Code Online (Sandbox Code Playgroud)

0x7ffeae3b3674

然后,我将上述地址应用于第一个程序。

c pointers

4
推荐指数
2
解决办法
103
查看次数

Why trying to print the result of subtraction of two pointers throwing warning?

I am trying to subtract 2 pointers such that they such give the number of elements.I could compile the program and run it .But after compilation it is throwing error as

pointerarithmetic.c: In function ‘main’:
pointerarithmetic.c:9:8: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
 printf("%d",(q-p));
Run Code Online (Sandbox Code Playgroud)

The code:

#include<stdio.h>

    int main(){
    int a[5]={0,10,20,30,40};
    int *p,*q;
    p=&a[0];
    q=&a[2];
    printf("%d",*p);
    printf("%d",*q);
    printf("%d",(q-p));
    return 0;
    }
Run Code Online (Sandbox Code Playgroud)

The expected output should be number of elements.

c pointers subtraction

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

如何在加载时调用此角度函数

我有一个异步函数getDataStandard(),需要在单击时执行。我需要不单击而自动完成该函数。怎么做。请帮助我,因为我刚接触离子。

async getDataStandard() {
    let loading = await this.loadingCtrl.create();
    await loading.present();

    this.http.get('https://www.labourguide.co.za/LabourguideApi/index.php?q=mostRecentPublications').pipe(
      finalize(() => loading.dismiss())
    )
    .subscribe(data => {
console.log("Testing ...............1");
      this.data = data;
console.log(data);
console.log("Testing ..............2");
    }, err => {
      console.log('JS Call error: ', err);
    });
  }
Run Code Online (Sandbox Code Playgroud)

这是离子部分

 <ion-button expand="block" (click)="getDataStandard()">getDataStandard</ion-button>
Run Code Online (Sandbox Code Playgroud)

json ionic-framework angular

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

标签 统计

c ×2

pointers ×2

angular ×1

ionic-framework ×1

json ×1

subtraction ×1