我正在尝试编写这段代码,但是在运行程序后它给了我分段错误,你能帮忙解决一下吗?
#include <stdio.h>
#include <string.h>
typedef struct{
int salary;
char* name;
} employee ;
int main(){
employee p[2];
int i;
for(i=0;i<2; i++){
printf("enter sal ");
scanf("%d", &p[i].salary);
printf("enter name ");
scanf("%s", &p[i].name);
}
for(i=0;i<2; i++){
printf("p %d",p[i].salary);
printf("p %s",p[i].name);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我有以下代码.我想用这个信息来创建一个.bmp文件,它显示来自内存的数据,这是一个从framegrabber复制到主内存的图像,有人可以告诉我吗?谢谢
LPSTR CreateBMP( HWND hAppWnd, int nImageType )
Run Code Online (Sandbox Code Playgroud)
{
void*pWinGBits = NULL; int i; Z_BITMAPINFO zWinGHeader; //用于缓存DIB的bitmapinfo
// create DC for bitmap.
hDCBits = CreateCompatibleDC( ghDCMain );
switch ( nImageType )
{
case bayer_filter:
zWinGHeader.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
zWinGHeader.bmiHeader.biPlanes = 1;
zWinGHeader.bmiHeader.biClrImportant = 0;
zWinGHeader.bmiHeader.biHeight = -lYSize;
zWinGHeader.bmiHeader.biWidth = lXSize;
zWinGHeader.bmiHeader.biBitCount = 32;
zWinGHeader.bmiHeader.biClrUsed = 0;//3;
zWinGHeader.bmiHeader.biCompression = BI_BITFIELDS;
zWinGHeader.bmiHeader.biSizeImage = 0;
zWinGHeader.bmiColors[0].rgbBlue = 0x00;
zWinGHeader.bmiColors[0].rgbGreen = 0x00;
zWinGHeader.bmiColors[0].rgbRed = 0xFF;
zWinGHeader.bmiColors[0].rgbReserved = 0x00;
zWinGHeader.bmiColors[1].rgbBlue = 0x00;
zWinGHeader.bmiColors[1].rgbGreen = …Run Code Online (Sandbox Code Playgroud) 我在我的VMware上运行Mac Tiger,试图安装iphone SDK和Xcode,然后我发现我必须有豹子以便能够为Iphone开发.我想知道有没有适用于MAc Tiger 10.4的Iphone SDK和Xcode ??? 非常感谢
可以有人为我解释以下Perl代码吗?我认为它在Perl和我对Perl编程没有任何线索.请解释以下代码的作用?
$t = test(10);
sub test() {
my $str = unpack("B32", pack("N",shift));
$str2 = substr($str,16,length($str));
return $str2;
}
Run Code Online (Sandbox Code Playgroud) 我有以下代码,但我不确定%0x%x以下代码中的含义是什么?
sprintf(buf, "pixel : %0x%x \n", gpbImageData[100]);
OutputDebugString(buf);
Run Code Online (Sandbox Code Playgroud)
gpbImageData[100] 指向内存中的图像数据.
我有以下代码,这是我正在遵循的算法的一部分.如你所见,我需要为10个不同的乐队做一些计算.最终我需要从每个波段重新创建一个图像的矩阵,问题是我不知道如何在while循环上创建/保持10个不同的矩阵,然后在while循环后我可以构造图像一个接一个.如果您有任何想法请告诉我,谢谢
cv::Mat _reconstructionMatrix(height,width,CV_8UC1);
_reconsPointer = _reconstructionMatrix.ptr<uchar>(0);
while(_bandIteration<_bandsNumber){
if(_mainMatrix.isContinuous())
{
nCols *= nRows;
nRows = 1;
}
//for all the pixels
for(int i = 0; i < nRows; i++)
{
p = _mainMatrix.ptr<uchar>(i);
//in the images
for (int j = 0; j < nCols; j++)
{
if(_pCounter<_totalImgNO){
....
}else{
...
_reconsPointer[_resultFlag]=_summation;
_resultFlag++;
...
}
}
}
_bandIteration++;
}
Run Code Online (Sandbox Code Playgroud)