给一个二维数组随机赋值
#include <stdio.h> #include <iostream> void main() { const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; const int dimon = 10; const int size = 11; char **data = new char*[dimon*size]; for (int i = 0; i < dimon; i++) { data[i]=new char[size]; memset(data[i],0,size); } for (int i = 0; i < dimon; i++) { memcpy(data[i],"Gh0st",5); for (int j = 5; j < size; j++) { data[i][j] =alphanum[rand() % (sizeof(alphanum) - 1)]; } } getchar(); return; }
运行后, 在 immidiatly 窗口可以查询到
data[0]
0x008b6f00 "Gh0stfrAQBcýýýý««««««««þîþîþîþîþ"
data[1]
0x008b45e8 "Gh0st8Wsa1xýýýý««««««««þ"
data[1]
0x00b745e8 "Gh0st8Wsa1xýýýý««««««««þ"
data[2]
0x00b74630 "Gh0stVPfvJcýýýý««««««««þ"
data[3]
0x00b7af48 "Gh0strgRYwTýýýý««««««««þ"
data[4]
0x00b7af90 "Gh0stiizs2týýýý««««««««þ"
data[5]
0x00b7b9d0 "Gh0strQF69Aýýýý««««««««þ"
data[6]
0x00b7ba18 "Gh0stzBlax3ýýýý««««««««þ"