我的代码如下,
#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)
我得到了分段错误!知道为什么?? 在此先感谢您的帮助
我想声明一个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组
我使用了这个显示错误的代码:即,如果我的米是175米,但是当我转换它时,它没有显示那个东西
<?php
function metersToFeetInches($meters, $echo = true)
{
$m = $meters;
$valInFeet = $m*3.2808399;
$valFeet = (int)$valInFeet;
$valInches = round(($valInFeet-$valFeet)*12);
$data = $valFeet."′".$valInches."″";
if($echo == true)
{
echo $data;
} else {
return $data;
}
}
?>
<?php
$feetInches = metersToFeetInches(1.75,false);
echo $feetInches;
?>
Run Code Online (Sandbox Code Playgroud) 我有一本字典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.我怎样才能做到这一点?