分类: 编程语言

php 只替换字符串中第一次出现的字符

字符串:abcdefgabchijklmn 查找对象:abc 替换内容:123 最终效果:123defgabchijklmn $str = "abcdefgabchijklmn"; $needle = "abc"; $result = substr_replace($str,"123",strpos($str,$needle),strlen($needle)); var_dump($result);

Win32 根据客户区大小创建窗口

CWnd::CalcWindowRect 传入客户区大小,返回窗口大小  使用CWnd::SetWindowPos 设置窗口大小,使用这个函数之前必须调用计算函数 // 用于保存窗口大小 RECT rect; // 指定客户区大小(赋值) SetRect(&rect,0,0,100,100); //传入客户区的窗口大小,传入窗口风格,返回窗口的大小 AdjustWindowRect(&rect,WS_OVERLAPPED…

上位机和下位机的区别

上位机:计算机 属于决策者 下位机:单片机 属于执行者 区别 1、主体不同 上位机可以直接发出操控命令的计算机。而下位机直接控制设备获取设备状况的计算机,一般是PLC/单片机之类的。 2、通讯协议不同 上位机使用TCP/IP,或者RS232的串口通讯或者采用RS485串行通讯。而下位机具有更可靠的独有通讯协议。 3、工作方式不同 …

STL vector

#include <vector> using namespace std; 定义vector  vector ListData; 添加元素  ListData.push_back(1); 获取元素数量  ListData.size(); 清空元素  ListData.clear(); 遍历 if (!ListData.empty()) { for (auto ListDataIterator = ListData.begin(); ListDataIterator != ListData.end(); ++ListDataIterator) { // 在这里处理 ListData…

WPF布局

可以理解为一个表格,类似于HTML中的#Table标签。它是由行和列组成。 Gird <Grid> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefiniti…

STL vector 逗号分割保存到字符串中

#include <iostream> #include <vector> #include <string> int main() { std::vector<std::string> numbers = {"111", "abc", "123"}; std::string result; for (const auto& num : numbers) { if (!result.empty()) { result += ","; } result += n…