小编pst*_*jds的帖子

将结构内部使用的void*指针类型转换为int*指针时出现问题!

我的代码如下,

#include<stdio.h>
struct data
{
    int a ;
    void *b;
};

int main()
{
    struct data *d;
    int *ptr;

    int key=10000;
    d->b=&key;

    ptr=(int *)d->b;
    printf("%d\n",*ptr);
}
Run Code Online (Sandbox Code Playgroud)

我得到了分段错误!知道为什么?? 在此先感谢您的帮助

c

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

如何声明handel数组?

我想声明一个handel数组,如下面的代码:

using namespace System::Drawing;
ref class B 
{
    Bitmap^ b[];

    B()
    {
        b = new Bitmap^[10];
    }
};
Run Code Online (Sandbox Code Playgroud)

但是在编译时它会抛出错误

error C2728: 'System::Drawing::Bitmap ^' : a native array cannot contain this managed type
error C4368: cannot define 'b' as a member of managed 'B': mixed types are not supported
error C2728: 'System::Drawing::Bitmap ^' : a native array cannot contain this managed type
error C2440: '=' : cannot convert from 'System::Drawing::Bitmap ^*' to 'System::Drawing::Bitmap ^[]'
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我正确的方式来声明一个handel数组吗?

非常感谢!

T&T组

.net c++ arrays collections c++-cli

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

如何使用PHP将米转换为英尺

我使用了这个显示错误的代码:即,如果我的米是175米,但是当我转换它时,它没有显示那个东西

<?php
function metersToFeetInches($meters, $echo = true)
{
    $m = $meters;
    $valInFeet = $m*3.2808399;
    $valFeet = (int)$valInFeet;
    $valInches = round(($valInFeet-$valFeet)*12);
    $data = $valFeet."&prime;".$valInches."&Prime;";
    if($echo == true)
    {
            echo $data;
    } else {
            return $data;
    }
}
?>
<?php
$feetInches = metersToFeetInches(1.75,false);
echo $feetInches;
?>
Run Code Online (Sandbox Code Playgroud)

php

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

C#字典过滤(LINQ)值并获取密钥

我有一本字典fooDictionary<string, MyObject>.

我正在过滤fooDictionary以获取MyObject具有该属性的特定值的唯一值.

//(Extension method is a extension method that I made for the lists
//(PS: ExtensionMethod returns only 1x MyObject))
fooDictionary.Values.Where(x=>x.Boo==false).ToList().ExtensionMethod(); 
Run Code Online (Sandbox Code Playgroud)

但我也希望获得已经过滤的密钥MyObject's.我怎样才能做到这一点?

c# linq dictionary

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

标签 统计

.net ×1

arrays ×1

c ×1

c# ×1

c++ ×1

c++-cli ×1

collections ×1

dictionary ×1

linq ×1

php ×1