user-0 提问: 运行时出现了debug  assretion failed 问题，麻烦大神帮忙解决

回复:
user: user-1
content: 代码功能归根结底不是别人帮自己看或讲解或注释出来的；而是被自己静下心来花足够长的时间和精力亲自动手单步或设断点或对执行到某步获得的中间结果显示或写到日志文件中一步一步分析出来的。 提醒：再牛×的老师也无法代替学生自己领悟和上厕所！ 单步调试和设断点调试（VS IDE中编译连接通过以后，按F10或F11键单步执行，按Shift+F11退出当前函数；在某行按F9设断点后按F5执行停在该断点处。）是程序员必须掌握的技能之一。

user: user-2
content: 出错时点中断，通过调用堆栈定位到相关位置，观察分析原因  必要时可设置断点，然后单步跟踪程序运行

user: user-0
content: /*16.加密总函数*/ void DataEncrypt(char *k, unsigned char key[][4], unsigned char bit[], FILE *fp1, FILE *fp2, unsigned char RoundKey[][4], unsigned char status[][4]) {     int sum, numOfBlock, numOfSurplus;     char ch;     int len = strlen(k);     if (len != 16){         free(k);         printf("\n\n输入密钥长度不满足要求!\n"); return;     }     KeyExpansion(k, key, bit);     sum = SumBytes(fp1);     fp1 = fopen("源文件.txt", "r");     numOfBlock = sum / 16;     numOfSurplus = sum % 16;      ch = fgetc(fp1);     /*第一种情况*/     if (numOfBlock != 0 && numOfSurplus == 0){         for (int n = 1; n <= numOfBlock; n++){             for (int i = 0; i < 4; i++)             for (int j = 0; j < 4; j++){                 status[i][j] = ch;                 ch = fgetc(fp1);             }//status赋值              RoundKeyChoice(key, RoundKey, 0);             AddRoundKey(RoundKey, status);             for (int nr = 1; nr <= 10; nr++){                 SubBytes(status, bit);                 ShiftRows(status);                 MixColumns(status);                 RoundKeyChoice(key, RoundKey, nr);                 AddRoundKey(RoundKey, status);             }//10轮加密             SubBytes(status, bit);             ShiftRows(status);             RoundKeyChoice(key, RoundKey, 4);             AddRoundKey(RoundKey, status);             BytesWrite(fp2, status);         }//Block循环     }//if     //第二种情况     else if (numOfBlock == 0 && numOfSurplus != 0){         for (int i = 0; i < 4; i++)         for (int j = 0; j < 4; j++){             if (ch == EOF) break;             status[i][j] = ch;             ch = fgetc(fp1);         }         for ( i = sum / 4; i < 4; i++)         for (int j = sum % 4; j < 4; j++)             status[i][j] = 0x00;         RoundKeyChoice(key, RoundKey, 0);         AddRoundKey(RoundKey, status);         for (int nr = 1; nr <= 10; nr++){             SubBytes(status, bit);             ShiftRows(status);             MixColumns(status);             RoundKeyChoice(key, RoundKey, nr);             AddRoundKey(RoundKey, status);         }//10轮加密         SubBytes(status, bit);         ShiftRows(status);         RoundKeyChoice(key, RoundKey, 4);         AddRoundKey(RoundKey, status);         BytesWrite(fp2, status);     }//else if     //第三种情况     else if (numOfBlock != 0 && numOfSurplus != 0){         for (int n = 1; n <= numOfBlock; n++){             for (int i = 0; i <4; i++)             for (int j = 0; j < 4; j++){                 status[i][j] = ch;                 ch = fgetc(fp1);             }//status赋值              RoundKeyChoice(key, RoundKey, 0);             AddRoundKey(RoundKey, status);             for (int nr = 1; nr <= 10; nr++){                 SubBytes(status, bit);                 ShiftRows(status);                 MixColumns(status);                 RoundKeyChoice(key, RoundKey, nr);                 AddRoundKey(RoundKey, status);             }//10轮加密             SubBytes(status, bit);             ShiftRows(status);             RoundKeyChoice(key, RoundKey, 4);             AddRoundKey(RoundKey, status);             BytesWrite(fp2, status);         }//Block循环         for (int i = 0; i < 4; i++)         for (int j = 0; j < 4; j++){             if (ch == EOF) break;             status[i][j] = ch;             char ch = fgetc(fp1);         }         for ( i = sum / 4; i < 4; i++)         for (int j = sum % 4; j < 4; j++)             status[i][j] = 0x00;         RoundKeyChoice(key, RoundKey, 0);         AddRoundKey(RoundKey, status);         for (int nr = 1; nr <= 10; nr++){             SubBytes(status, bit);             ShiftRows(status);             MixColumns(status);             RoundKeyChoice(key, RoundKey, nr);             AddRoundKey(RoundKey, status);         }//10轮加密         SubBytes(status, bit);         ShiftRows(status);         RoundKeyChoice(key, RoundKey, 4);         AddRoundKey(RoundKey, status);         BytesWrite(fp2, status);     }//else      free(k);     fclose(fp1);     fclose(fp2);     printf("\n\n加密文件成功!\n\n"); }  /*17.解密总函数*/ void DataDecrypt(char *k1, unsigned char key[][4], FILE *fp1, FILE *fp2, unsigned char status[][4], unsigned char RoundKey[][4], unsigned char bit[]) {     int numOfBlock, sum;     char ch;     int len = strlen(k1);     if (len != 16){         free(k1);         printf("\n\n输入密钥长度不满足要求!\n"); return;     }     sum = SumBytes(fp1);     fp1 = fopen("加密后文件.txt", "r");     numOfBlock = sum / 16;      ch = fgetc(fp1);     for (int i = 1; i <= numOfBlock; i++){         for (int i = 0; i < 4; i++)         for (int j = 0; j < 4; j++){             status[i][j] = ch;             ch = fgetc(fp1);         }         RoundKeyChoice(key, RoundKey, 4);         AddRoundKey(RoundKey, status);         Inv_ShiftRows(status);         Inv_SubBytes(status, bit);         for (int nr = 10; nr >= 1; nr--){             RoundKeyChoice(key, RoundKey, nr);             AddRoundKey(RoundKey, status);             Inv_MixColumns(status);             Inv_ShiftRows(status);             Inv_SubBytes(status, bit);         }//10轮解密          RoundKeyChoice(key, RoundKey, 0);         AddRoundKey(RoundKey, status);         BytesWrite(fp2, status);     }//Block     free(k1);     fclose(fp1);     fclose(fp2);     printf("\n\n解密文件成功!\n\n"); }  int main(){     int choice, sum1;     int flag = 1;     char *k, *k1;     FILE *fp1, *fp2;     unsigned char status[4][4] = { 0x00 };     unsigned char key[44][4] = { 0x00 };     unsigned char RoundKey[4][4] = { 0x00 };     unsigned char bit[8] = { 0x00 };     do{         printf("*****************************AES加密解密文件************************************");         printf("\n");         printf("                             1.加密文件\n\n");         printf("                             2.解密文件\n\n");         printf("                             3.退出\n\n");         printf("\n请选择要进行的操作:");         scanf("%d", &choice);         switch (choice){         case 1: fp1 = fopen("C://Users/WUWEI/Desktop/123/Debug/源文件.txt", "r");             if (fp1 == NULL){                 printf("打开源文件失败!\n");                 getchar();                 exit(0);             }             fp2 = fopen("加密后文件.txt", "w");             if (fp2 == NULL){                 printf("打开加密后文件失败!\n");                 getchar();                 exit(0);             }             printf("\n请输入加密密钥(128bit):");             k = (char *)malloc(20 * sizeof(char));             cin >> k;             DataEncrypt(k, key, bit, fp1, fp2, RoundKey, status);             break;         case 2: fp1 = fopen("加密后文件.txt", "r");             if (fp1 == NULL){                 printf("\n打开加密后文件失败!\n");                 getchar();                 exit(0);             }             fp2 = fopen("解密后文件.txt", "w");             if (fp2 == NULL){                 printf("\n打开解密后文件失败!\n");                 getchar();                 exit(0);             }             printf("\n\n请输入解密密钥(128bit):");             k1 = (char *)malloc(20 * sizeof(char));             cin >> k1;             DataDecrypt(k1, key, fp1, fp2, status, RoundKey, bit);             break;         case 3: flag = 0; break;         default: printf("\n\n所选操作不合法!\n");         }//switch     } while (flag); }

user: user-3
content: 崩溃的时候在弹出的对话框按相应按钮进入调试，按Alt+7键查看Call Stack即“调用堆栈”里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处，看不懂时双击下一行，直到能看懂为止。