Talk about using C++ multi level pointer to store massive qq number and password

  • 2020-06-03 07:20:38
  • OfStack

Pointers are an important part of c++.

The needle is arguably the sharpest part of C++, and of course you can hurt yourself if you don't use it properly

In this blog post, I will try to store a large number of QQ Numbers and passwords using the structure of 11-level Pointers. First of all, for the record, I do not have massive QQ number and password, just want to use this structure to solve the problem that does not exist, does not exist only for me, it is said that Tencent's internal 1 code to the QQ processing is using this structure

What is a level 11 pointer, in fact, is to add 11 * in front of the pointer, plus 1 * is a level 1 pointer, plus 2 * is a level 2 pointer


char *********** QQptr = NULL; 

Pointer and array have a confused relationship, this 11 level pointer, you can understand as an array of 11 dimensions, usually see most is probably a 2-dimensional array, 11 dimension, can only imagine. If the QQ number is less than 10 digits long, the 0 is added before the QQ number, and the 10-digit QQ number can be used as the subscript of the array. The last dimension is used to store the password.

Frankly speaking, This model is too vague in my mind to establish a valid concept, so I'd better directly code, maybe code has a better interpretation effect than language:


#include <iostream> 
using namespace std; 
 
#define POINTER_SIZE 10 
 
 
int CharToInt(char ch) 
{ 
  return ch - '0'; 
} 
char *********** QQptr = NULL; 
void addQQ(char *qq,char* pass) 
{ 
  if(NULL==qq || NULL==pass) 
  { 
    return ; 
  } 
 
  if(strlen(qq)!=10) 
  { 
    return; 
  } 
 
  int index[10]; 
  for(int i =0;i<10;i++) 
  { 
    index[i] = CharToInt(qq[i]); 
  } 
 
  if(QQptr[index[0]]==NULL) 
  { 
    QQptr[index[0]] = (char **********)malloc(sizeof(char*)* POINTER_SIZE); 
    memset(QQptr[index[0]], 0, sizeof(char*)* POINTER_SIZE);// reset  
  } 
 
  if(QQptr[index[0]][index[1]]==NULL) 
  { 
    QQptr[index[0]][index[1]] = (char *********)malloc(sizeof(char*)* POINTER_SIZE); 
    memset(QQptr[index[0]][index[1]], 0, sizeof(char*)* POINTER_SIZE);// reset  
  } 
 
  if(QQptr[index[0]][index[1]][index[2]]==NULL) 
  { 
    QQptr[index[0]][index[1]][index[2]] = (char ********)malloc(sizeof(char*)* POINTER_SIZE); 
    memset(QQptr[index[0]][index[1]][index[2]], 0, sizeof(char*)* POINTER_SIZE);// reset  
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]]==NULL) 
  { 
    QQptr[index[0]][index[1]][index[2]][index[3]] = (char *******)malloc(sizeof(char*)* POINTER_SIZE); 
    memset(QQptr[index[0]][index[1]][index[2]][index[3]], 0, sizeof(char*)* POINTER_SIZE);// reset  
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]]==NULL) 
  { 
    QQptr[index[0]][index[1]][index[2]][index[3]][index[4]] = (char ******)malloc(sizeof(char*)* POINTER_SIZE); 
    memset(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]], 0, sizeof(char*)* POINTER_SIZE);// reset  
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]]==NULL) 
  { 
    QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]] = (char *****)malloc(sizeof(char*)* POINTER_SIZE); 
    memset(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]], 0, sizeof(char*)* POINTER_SIZE);// reset  
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]]==NULL) 
  { 
    QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]] = (char ****)malloc(sizeof(char*)* POINTER_SIZE); 
    memset(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]], 0, sizeof(char*)* POINTER_SIZE);// reset  
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]]==NULL) 
  { 
    QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]] = (char ****)malloc(sizeof(char*)* POINTER_SIZE); 
    memset(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]], 0, sizeof(char*)* POINTER_SIZE);// reset  
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]]==NULL) 
  { 
    QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]] = (char ***)malloc(sizeof(char*)* POINTER_SIZE); 
    memset(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]], 0, sizeof(char*)* POINTER_SIZE);// reset  
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]][index[8]]==NULL) 
  { 
    QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]][index[8]] = (char **)malloc(sizeof(char*)* POINTER_SIZE); 
    memset(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]][index[8]], 0, sizeof(char*)* POINTER_SIZE);// reset  
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]][index[8]][index[9]]==NULL) 
  { 
    QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]][index[8]][index[9]] = (char *)malloc(sizeof(char*)* 1024); 
    memset(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]][index[8]][index[9]], 0, sizeof(char*)* POINTER_SIZE);// reset  
  } 
 
  strcpy(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]][index[8]][index[9]],pass); 
} 
 
bool isExist(char *qq) 
{ 
  if(NULL==qq) 
  { 
    return NULL ; 
  } 
 
  if(strlen(qq)!=10) 
  { 
    return NULL; 
  } 
 
  int index[10]; 
  for(int i =0;i<10;i++) 
  { 
    index[i] = CharToInt(qq[i]); 
  } 
 
  if(QQptr[index[0]]==NULL) 
  { 
    return false; 
  } 
 
  if(QQptr[index[0]][index[1]]==NULL) 
  { 
    return false; 
  } 
 
  if(QQptr[index[0]][index[1]][index[2]]==NULL) 
  { 
    return false; 
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]]==NULL) 
  { 
    return false; 
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]]==NULL) 
  { 
    return false; 
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]]==NULL) 
  { 
    return false; 
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]]==NULL) 
  { 
    return false; 
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]]==NULL) 
  { 
    return false; 
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]]==NULL) 
  { 
    return false; 
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]][index[8]]==NULL) 
  { 
    return false; 
  } 
 
  if(QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]][index[8]][index[9]]==NULL) 
  { 
    return false; 
  } 
  return true; 
} 
char* getPass(char* qq) 
{ 
  if(NULL==qq) 
  { 
    return NULL ; 
  } 
 
  if(strlen(qq)!=10) 
  { 
    return NULL; 
  } 
 
  if(!isExist(qq)) 
  { 
    return NULL; 
  } 
 
  int index[10]; 
  for(int i =0;i<10;i++) 
  { 
    index[i] = CharToInt(qq[i]); 
  } 
  return QQptr[index[0]][index[1]][index[2]][index[3]][index[4]][index[5]][index[6]][index[7]][index[8]][index[9]]; 
} 
int main() 
{ 
   
  QQptr = (char ***********)malloc(sizeof(char*)* POINTER_SIZE); 
  memset(QQptr, 0, sizeof(char*)* POINTER_SIZE);// reset  
   
  char *qq = "0381084992"; 
  char *pass = "314krtqw"; 
   
  addQQ(qq,pass); 
  cout<<getPass(qq)<<endl; 
  return 0; 
} 

conclusion

Above is the paper on the use of C++ multi-level pointer storage of massive qq number and password, I hope to help you. Interested friends can continue to refer to other related topics in this site, if there is any deficiency, welcome to comment out. Thank you for your support!


Related articles: