|
发表于 2007-12-25 09:15:00
|
显示全部楼层
Re:memcpy()
- #include <string>
- void foo()
- {
- char c[64] = "abcdefghij";
- std::string temp;
- std::string temp1;
- temp.assign(c, 5);
- temp1.assign(c+5, 5);
- MessageBoxA(NULL, temp.c_str(), "msg", MB_OK);
- MessageBoxA(NULL, temp1.c_str(), "msg", MB_OK);
- char temp2[64];
- char temp3[64];
- memcpy(temp2, c, 5);
- temp2[5] = '\0';
- memcpy(temp3, c+5, 5);
- temp3[5] = '\0';
- MessageBoxA(NULL, temp2, "msg", MB_OK);
- MessageBoxA(NULL, temp3, "msg", MB_OK);
- }
复制代码
顺便问一句,你的是MFC项目还是win32项目? |
|