Skip to content

随机字符串 #44

@holdyounger

Description

@holdyounger

随机字符串

	qsrand(QDateTime::currentMSecsSinceEpoch());
	const char ch[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int size = sizeof(ch);
	char* str = new char[nLen + 1];
	int num = 0;
	for (int nIndex = 0; nIndex < nLen; ++nIndex)
	{
		num = rand() % (size - 1);
		str[nIndex] = ch[num];
	}
	str[nLen] = '\0';

	QString res(str);

    QLOG_INFO() << __FUNCTION__ << __LINE__ << res;

    m_RandomCode = res;

blog link [随机字符串](https://holdyounger.github.io/Code/Qt/Qt 随机字符串/)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions