我不明白为什么会这样.我可以调用read_png_file()和*数据(如果我设置了,我可以看到值设置).但是当我调用next函数时,那里没有数据,但它是类型(PNGDataPtr*)0x22ff24引用(PNGDataPtr)0x77c02850你能解释一下那里发生了什么以及它是如何正确的?我想传递结构并在函数之间共享它.
#include <stdio.h>
#include <stdlib.h>
#include <png.h>
typedef struct
{
FILE *fp;
} PNGData, *PNGDataPtr;
void read_png_file(char* file_name, PNGData * data)
{
}
void write_png_file(char* file_name, PNGDataPtr * data)
{
}
void process_file(PNGDataPtr * data)
{
}
int main(int argc, char **argv)
{
PNGData data;
read_png_file(argv[1], &data);
process_file(&data);
write_png_file(argv[2], &data);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
功能'主':|
警告:从不兼容的指针类型
main.c 传递'process_file'的参数1 | 19 |注意:期望'struct**'但参数的类型为'struct PNGData*'|
警告:从不兼容的指针类型[默认启用] |传递'write_png_file'的参数2
15 |注意:预期'struct**'但参数的类型为'struct PNGData*'|
我有包含数组的对象,我希望它包含关联数组,因此键是字符串.怎么做?这不起作用:
{profiles: { easy:["example" : 1],advanced:["example" : 1] }
Run Code Online (Sandbox Code Playgroud)
我想避免
console.log({profiles: { easy:{"example" : 1},advanced:{"example" : 1} })
Run Code Online (Sandbox Code Playgroud)
因为简单和高级成员不会显示为数组而是显示为对象.
我知道的另一种方法是:array ['key2'] ='新值'; 但这不是对象的一部分,所以我需要拆分多行的命令 - 这不是我想要的.
PHP有类似数组("mykey"=>"myValue"),但JavaScript有类似的东西吗?
但我不想使用框架,这只是JavaScript.
我有正则表达式
(?<=\s)(?:#sidebar-right-1|#BlogArchive1|#ArchiveList|#BlogArchive1_ArchiveList|#PopularPosts)(?=\s|{)
我收到语法错误无效的正则表达式组。问题在哪里?
我像这样应用它:
Rules [r] .selectorText.match(new RegExp(ids,'gm'))
我试图从函数readfile访问名为buf的缓冲区.当我打印sizeof(buf)时,我看到buf有4个字节(指针).另一方面,如果我在readFiles上粘贴printf命令,我可以看到大小是2916.实际上,我不明白为什么它不是729,但很明显我无法访问readfile里面的buf我需要.所以问题是; 问题在哪里以及如何纠正?
void readfiles(FILES * files){
unsigned char * buf [1*729];
int skip_lines = 14;
int shift = 0;
char * filename = "file.txt";
// printf("buf size %d", sizeof(buf));
readfile(filename, skip_lines, buf, shift);
}
int readfile(char * name, int skip, unsigned char * buf, int shift ){
// buf is (unsigned char *) on address 0x22dd18 ""
printf("buf size %d", sizeof(buf));
}
Run Code Online (Sandbox Code Playgroud) 我尝试在第一次调用函数时将静态变量初始化为 1。如何正确地做到这一点?这是类型不匹配错误。
Static clip_success As Integer
If clip_success Is Nothing Then
clip_success = 1
End If
Run Code Online (Sandbox Code Playgroud) 我试图创建一个函数/方法,它应该写入一个带有填充零的标题的文件
header := StringOfChar(char(0), 11*offsetSize);
Run Code Online (Sandbox Code Playgroud)
但是当我检查创建的文件时,它具有以下值(十六进制):
C026A200160000000100000006000000264C656B63650000B2000000B04D45005C1EA200306CA20000000000
Run Code Online (Sandbox Code Playgroud)
我希望输出文件应该包含
0000 0000 0000 0000 0000 0000
Run Code Online (Sandbox Code Playgroud)
然后我也尝试填充它,chr(1)结果是类似的:
C026A200160000000100000006000000264C656B63650000B2000000B04D45005C1EA200306CA20000000000
Run Code Online (Sandbox Code Playgroud)
(看起来一样).
当我在Delphi 7中调试时,我在用零填充时观察标题:
#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
Run Code Online (Sandbox Code Playgroud)
当我填写它chr(1)然后它包含...
#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,为什么会发生这种情况?输出文件包含错误的数据我做错了什么?
unit Dictionary_io;
interface
uses
Classes, Windows, SysUtils, Dialogs;
const
offsetTableEntriesCount = 10;
type
TCountType = dword;
TOffsetType = dword;
TTextType = ANSIString;
const
testItemsCount = 1;
type
Dictionary = class
private
fsInput, fsOutput: TFileStream;
fileName: string;
msOffsets: TMemoryStream;
offsetSize: TOffsetType;
ofsTableEntries: TCountType;
lng: integer;
itemsCount: byte;
header: TTextType;
public
constructor Create;
procedure dicRewrite; …Run Code Online (Sandbox Code Playgroud) 我正在使用 Delphi 7,我尝试在 CEF4 Delphi 中编译名为 uWebBrowser (OSRDLLBrowser.dpr) 的演示应用程序,但出现错误:
TempSrcOffset := ((dirtyRects[n].y * Width) + dirtyRects[n].x) * SizeOf(TRGBQuad);
TempDstOffset := ((TempScanlineSize * pred(TempHeight)) - (dirtyRects[n].y * TempScanlineSize)) +
(dirtyRects[n].x * SizeOf(TRGBQuad));
src := @PByte(buffer)[TempSrcOffset];
dst := @PByte(TempBufferBits)[TempDstOffset];
Run Code Online (Sandbox Code Playgroud)
[错误] uWebBrowser.pas(455): 需要数组类型
我明白,这 src := @PByte(buffer)[TempSrcOffset];是试图分配不是数组的值,但你能解释为什么以及如何解决它吗?
笔记:
现在我正在使用这些二进制文件:https : //github.com/salvadordf/OldCEF4Delphi使用 D7,OS XP 32 位,工作正常。
假设我有动态数组
type TCharArr = Array of byte;
type PcharArr = ^TCharArr;
var charArr: PcharArr;
Run Code Online (Sandbox Code Playgroud)
我希望以新的方式在Heap中分配内存(charArr);
但是,如何指定大小和索引?动态数组是否有可能具有索引,例如.从512 ..到1024?
是否有可能将TMistakes2D添加到类TForm1中?
type
TMistakes2D: array of TStringList;
end;
type
TForm1 = class(TForm)
mistakes2D: TMistakes2D;
end;
Run Code Online (Sandbox Code Playgroud)
这打印错误......
Field Form1.mistakes2D没有相应的组件.删除声明?
我正在尝试使用工作代码来替换行的文本.使用boost_1_64_0.
getline (ifs, line);
cout << line << endl;
// 1.
boost::replace_all(line, "abc", "hij");
boost::replace_all(line, "def", "klm");
// 2.
line = boost::replace_all_copy
boost::replace_all_copy<string>
(
("abc def abc def", "abc", "hij")
, "def"
, "klm"
);
Run Code Online (Sandbox Code Playgroud)
我收到这些错误:
main.cpp||In function 'int main()':|
main.cpp|37|error: no match for 'operator=' in 'line = boost::algorithm::replace_all_copy'|
main.cpp|37|note: candidates are:|
\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|543|note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string<char>]|
mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|543|note: no known …Run Code Online (Sandbox Code Playgroud) delphi ×4
arrays ×2
c ×2
javascript ×2
pointers ×2
boost ×1
c++ ×1
filestreams ×1
match ×1
ms-office ×1
regex ×1
tfilestream ×1
vba ×1