推荐 最新
万码用户

baidu/dperf

该项目是基于 DPDK 开发的高性能压测工具,能够每秒建立千万级的 HTTP 连接、亿级别的并发请求和数百 Gbps 的吞吐量。

14
0
0
浏览量38
万码用户

c语言EXC_BAD_ACCESS (code=2, address=0x102a3bf74)

我的代码如下: #include #include void permutation(char str[], int len, int cur) { if (cur == len - 1) { printf("%s\n", str); } char tmp; for (int i = cur; i < len; i++) { tmp = str[cur]; str[cur] = str[i]; str[i] = tmp; permutation(str, len, cur++); tmp = str[cur]; str[cur] = str[i]; str[i] = tmp; } } int main() { char* str = "abc"; int len = strlen(str); permutation(str, len, 0); } 在str[cur] = str[i]这里报EXC_BAD_ACCESS ,但是我又不知道问题出在哪。还请各位大佬帮忙看看。 "https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1724816070910_8RDd.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1724816070910_8RDd.png)

0
1
0
浏览量211
万码JFG3236P

为什么qt在槽函数里无法对qfile对象进行操作啊?

QFile fi("/home/zhzhy/1.cpp"); int flag=fi.open(QIODevice::ReadWrite); fi.write("abc"); connect(&u,&QUdpSocket::readyRead,[&] { fi.write("def");}); 大概是这么个情形. 我发现abc可以正常打印,但运行到def直接崩溃了,这是为什么呢?

0
1
0
浏览量210
万码JFG3236P

对 nullptr 解引用会得到什么?

未定义行为。 程序可以出现任何行为,包括得到一个无意义的值、崩溃等等。崩溃应该是比较常见的结果。

0
1
0
浏览量209
万码JFG3236P

c++ 类名前的 宏定义的 作用?

#define SVG_IMP_EXP class SVG_IMP_EXP SVGDocument 这个代码中 SVG_IMP_EXP 作用是什么,看了些解释,还是不太懂,有没有大佬用通俗一点的语言告知下,还有些是加在 函数前的,又是什么作用?

0
1
0
浏览量209
万码JFG3236P

顺序存储,线性表的删除和插入中出现问题,未知代码哪里出错?

需求:编制C/C++程序,利用顺序存储方式实现下列功能:从键盘输入数据建立一个线性表(整数),并输出该线性表;然后根据屏幕提示,进行数据的插入或删除等操作,并在插入或删除数据后输出线性表。 代码出现问题,无法运行,错误提醒是delete那块红了,估计是它出问题。 未知是什么原因,望指教。 typedef struct { int data[MAX_SIZE]; int length; } SeqList; void init(SeqList *list) { list->length = 0; } void insert(SeqList *list, int position, int value) { if (position list->length || list->length == MAX_SIZE) { printf("The insert position is invalid or the linear table is full:\n"); return; } for (int i = list->length - 1; i >= position; i--) { list->data[i + 1] = list->data[i]; } list->data[position] = value; list->length++; } void delete(SeqList *list, int position) { if (position = list->length) { printf("Invalid delete location:\n"); return; } for (int i = position; i length - 1; i++) { list->data[i] = list->data[i + 1]; } list->length--; } void print(SeqList *list) { printf("Linear table contents:"); for (int i = 0; i length; i++) { printf("%d ", list->data[i]); } printf("\n"); } int main() { SeqList list; init(&list); printf("Please enter the length of the linear table:"); scanf("%d", &list.length); if (list.length > MAX_SIZE) { printf("The linear table length exceeds the maximum value:\n"); return 0; } printf("Enter the elements of the linear table:"); for (int i = 0; i < list.length; i++) { scanf("%d", &list.data[i]); } print(&list); int operation, position, value; printf("\nplese select:\n"); printf("1. insect the data:\n"); printf("2. delete the data\n"); printf("0. exit\n"); while (1) { printf("\nplease enter the ops:"); scanf("%d", &operation); if (operation == 1) { printf("Please enter insert position and insert value (separated by space):"); scanf("%d %d", &position, &value); insert(&list, position, value); } else if (operation == 2) { printf("Please enter the deletion location:"); scanf("%d", &position); delete(&list, position); } else if (operation == 0) { break; } else { printf("Invalid operation number:\n"); } print(&list); } return 0; } 顺便提问一句我的DEVC++底下变成这样,应该怎么恢复到初始可以看见报错原因的状态? "https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1724815714812_7GjD.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1724815714812_7GjD.png) 菜鸟上路,万分感谢指教。

0
1
0
浏览量209
万码JFG3236P

为什么通过swprintf_s拼接的路径无法用SHFileOperation删除文件?

如题,代码如下: WCHAR szPath[MAX_PATH] { L'\0' }; swprintf_s(szPath, MAX_PATH, L"%ls\\abc.txt\0", L"D:"); BOOL ret = PathFileExistsW(szPath); wprintf(L"%ls exists: %d\n", szPath, ret); SHFILEOPSTRUCT fileOp; fileOp.wFunc = FO_DELETE; fileOp.pFrom = szPath; fileOp.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; DWORD dwError = SHFileOperationW(&fileOp); wprintf(L"%ls delete ret: 0x%08X\n", szPath, dwError); 上述代码输出结果为: "https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1724813521743_TbEa.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1724813521743_TbEa.png) 只有手写路径才能删除成功,如fileOp.pFrom = L"D:\abc.txt\0" 通过swprintf_s拼接的路径字符串则失败

0
1
0
浏览量207
万码用户

macos 上这段程序应该链接什么库

#include #include #include int main() { CSIdentityQueryRef query = CSIdentityQueryCreateForCurrentUser(kCFAllocatorSystemDefault); CFErrorRef error; uint8 qdata[1024] = {0}; if (CSIdentityQueryExecute(query, kCSIdentityQueryGenerateUpdateEvents, &error)) { CFArrayRef foundIds = CSIdentityQueryCopyResults(query); if (CFArrayGetCount(foundIds) == 1) { CSIdentityRef userId = (CSIdentityRef) CFArrayGetValueAtIndex(foundIds, 0); CFDataRef data = CSIdentityGetImageData(userId); CFDataGetBytes(data, CFRangeMake(0, CFDataGetLength(data)), qdata); } } CFRelease(query); } 这段代码是获取当前用户的头像路径。 我用 g++ 编译的时候报错, ethson@macbookpro:~/Project/cpp_example$ g++ ./example.cpp -o exam Undefined symbols for architecture x86_64: "_CFArrayGetCount", referenced from: _main in example-7e578a.o "_CFArrayGetValueAtIndex", referenced from: _main in example-7e578a.o "_CFDataGetBytes", referenced from: _main in example-7e578a.o "_CFDataGetLength", referenced from: _main in example-7e578a.o "_CFRelease", referenced from: _main in example-7e578a.o "_CSIdentityGetImageData", referenced from: _main in example-7e578a.o "_CSIdentityQueryCopyResults", referenced from: _main in example-7e578a.o "_CSIdentityQueryCreateForCurrentUser", referenced from: _main in example-7e578a.o "_CSIdentityQueryExecute", referenced from: _main in example-7e578a.o "_kCFAllocatorSystemDefault", referenced from: _main in example-7e578a.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 我猜测是没有链接系统库造成的,但是我查了一圈,也没找到应该链接哪个库,求指教。

0
1
0
浏览量204
万码JFG3236P

特征码的通配符??和*号在vs里面怎么不能用?

uint8_t pattern[] = { 0x73, 0x3A, 0x??, 0x??, 0x??, 0x??, 0x20 }; 直接说是无效的十六进制数 "https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1724816971922_E9NT.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1724816971922_E9NT.png) "https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1724816988563_9oqf.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1724816988563_9oqf.png)

0
1
0
浏览量201
万码JFG3236P

cin和cout为什么比printf以及scanf慢?

cin和cout为什么比printf以及scanf慢? 我曾经搜索过,但是没有任何满意的答案 希望有大佬解答

0
1
0
浏览量199