我有一个使用VarLenType
我目前正在使用#include <H5Cpp.h>
typedef struct mytype_t {
double* dprop1;
double* dprop2;
int* iprop1;
double* dprop3;
} mytype_t;
H5::CompType ctype(sizeof(mytype_t));
auto double_type = H5::PredType::NATIVE_DOUBLE;
auto int_type = H5::PredType::NATIVE_INT;
auto vdouble_type = H5::VarLenType(&double_type);
auto vint_type = H5::VarLenType(&int_type);
ctype.insertMember("dProp1", HOFFSET(mytype_t, dprop1), vdouble_type);
ctype.insertMember("dProp2", HOFFSET(mytype_t, dprop2), vdouble_type);
ctype.insertMember("vProp1", HOFFSET(mytype_t, iprop1), vint_type);
ctype.insertMember("dProp3", HOFFSET(mytype_t, dprop3), vdouble_type);
std::vector<mytype_t> data_vector;
data_vector.resize(dims[0]*dims[1]);
dataset.read(data_vector.data(), ctype);
将const char* idname
与字符串进行比较。
例如:
strcmp
我真正想做的是以下内容:
idname
我该如何测试呢? 感谢
答案 0 :(得分:1)
有这样的库函数:
Since kernel 2.6.23, the Linux-specific /proc/PID/coredump_filter
file can be used to control which memory segments are written to the
core dump file in the event that a core dump is performed for the
process with the corresponding process ID.
The value in the file is a bit mask of memory mapping types (see
mmap(2)). If a bit is set in the mask, then memory mappings of the
corresponding type are dumped; otherwise they are not dumped. The
bits in this file have the following meanings:
bit 0 Dump anonymous private mappings.
bit 1 Dump anonymous shared mappings.
bit 2 Dump file-backed private mappings.
bit 3 Dump file-backed shared mappings.
bit 4 (since Linux 2.6.24)
Dump ELF headers.
bit 5 (since Linux 2.6.28)
Dump private huge pages.
bit 6 (since Linux 2.6.28)
Dump shared huge pages.
bit 7 (since Linux 4.4)
Dump private DAX pages.
bit 8 (since Linux 4.4)
Dump shared DAX pages.
By default, the following bits are set: 0, 1, 4 (if the
CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS kernel configuration option is
enabled), and 5. This default can be modified at boot time using the
coredump_filter boot option.
无论您的平台是使用ASCII还是其他内容,这些都可以正常工作。
答案 1 :(得分:0)
首先,你应该确保有第一个角色。
if (!idname || !*idname) return;
然后你可以比较你的第一个角色
char firstChar = idname[0];
对抗范围。 数字来自&#39; 0&#39; 0至&#39; 9&#39;或48至57。 小写英文字母来自&#39; a&#39;到&#39; z&#39;或97到122。 大写字母来自&#39; A&#39;至&#39; Z&#39;或65至90。 这适用于ASCII字符串。 Unicode可能需要更复杂的算法。
答案 2 :(得分:0)
const char* idname = 'a'; // or whatever
if (isalpha(idname )) {
if ( (int) idname >= 65 && (int) idname <= 90) foo = 2;
else if ( (int) idname >= 97 && (int) idname <= 122) foo = 3;
} else if (isdigit(c)) {
foo = 1;
}
这样的事情应该有用。检查一下,我没有测试过。 isalpha()和isdigit()是标准函数。