Po spuštení programu program normálně projede. Ale při opakování cyklu vyhodí windows okno že program přestal pracovat (to standartní windowsácké) .
Program
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char **argv)
{
/*Deklarace promených a nastaveni zakladnich aspektu pro chod programu*/
int Opak,r,s, velA_r,velAB_sr,velB_s;
int i,j,k;
unsigned int *MatA,*MatB,*MatC ,*zacA,*zacB,*zacC;
char Program;
Program=Opak=k=0;
/*Hlavni program, a jeho opakovani dokud neni zadana nula*/
/*cyklus opakovani, tak aby uzivatel nemusel pri kazdem novem nasobeni zapinat program*/
while(1){
srand((unsigned int) time(NULL));
printf("<----------Nasobeni Matic---------->\n");
printf("Pro ukonceni programu zadejte 0 \n\n");
printf("Zadej pocet radku matice A: "); scanf("%d",&velA_r);
if(velA_r==0)return 0;
printf("Zadej pocet sloupcu matice A==pocet radku matice B: ");scanf("%d",&velAB_sr);
printf("Pocet radku matice B: %d \n ",velAB_sr);
printf("Zadej pocet sloupcu matice B: ");scanf("%d",&velB_s);
MatA = (int*) malloc(velA_r *velAB_sr*sizeof(int));
MatB = (int*) malloc(velB_s *velAB_sr*sizeof(int));
MatC = (int*) malloc(velB_s *velA_r *sizeof(int));
zacA = MatA;
zacB = MatB;
zacC = MatC;
if (MatA == NULL||MatB == NULL||MatC == NULL)
{
printf("Malo pameti mas hochu!\n");
return 0;
}
printf("<-------------------------------->\nMatice A:\n");
for(r=0;r<velA_r;r++){
for(s=0;s<velAB_sr;s++){
*MatA=rand()%10;
printf("%d ",*MatA);
MatA++;
}
printf("\n");
}
srand((unsigned int) time(NULL));
printf("<-------------------------------->\nMatice B:\n");
for(r=0;r<velAB_sr;r++){
for(s=0;s<velB_s;s++){
*MatB=rand()%10;
printf("%d ",*MatB);
MatB++;
}
printf("\n");
}
printf("<-------------------------------->\nPronasobena Matice A s Matici B:\n");
/* vynulování matice C*/
for(r=0;r<velA_r;r++){
for(s=0;s<velB_s;s++){
*MatC=0;
MatC++;
}
}
/*Násobení matic vysledna matice je MatC*/
MatA=zacA;
MatB=zacB;
MatC=zacC;
k=velA_r*velB_s;
for(r=0;r<=k;r++){
MatA+=(velAB_sr*(r/velB_s));
MatB+=(r%velB_s);
for(s=0;s<velAB_sr;s++){
*MatC+=(*MatA)*(*MatB);
MatA++;
MatB+=velB_s;
}
MatC++;
MatA=zacA;
MatB=zacB;
}
/*vytiskne pronasobenou matici C*/
MatC=zacC;
for(r=0;r<velA_r;r++){
for(s=0;s<velB_s;s++){
printf("%3d ",*MatC);
MatC++;
}
printf("\n");
}
_getch();
free(MatA);
free(MatB);
free(MatC);
free(zacA);
free(zacB);
free(zacC);
}
return 0;
}
Výpis z debugu programu:
Program Received signal SIGTRAP
Single stepping until exit from function ntdll!TpWaitForAlpcCompletion, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!RtlGetDaclSecurityDescriptor, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!RtlCreateUserStack, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!AlpcMaxAllowedMessageLength, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!LdrWx86FormatVirtualImage, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!AlpcMaxAllowedMessageLength, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!LdrQueryProcessModuleInformation, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!AlpcMaxAllowedMessageLength, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!RtlGetLongestNtPathLength, \nwhich has no line number information.
Continuing...
Single stepping until exit from function wcstoul, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!RtlInitBarrier, \nwhich has no line number information.
Continuing...
Single stepping until exit from function wcstoul, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!EtwUnregisterTraceGuids, \nwhich has no line number information.
Continuing...
Single stepping until exit from function wcstoul, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!RtlRemovePrivileges, \nwhich has no line number information.
Continuing...
Single stepping until exit from function wcstoul, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!RtlInitBarrier, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!AlpcMaxAllowedMessageLength, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!RtlRemovePrivileges, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!RtlInitBarrier, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!EtwUnregisterTraceGuids, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!RtlInitBarrier, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!RtlRemovePrivileges, \nwhich has no line number information.
Continuing...
Single stepping until exit from function ntdll!RtlInitBarrier, \nwhich has no line number information.
Continuing...
Jeslti s tím někdo emá zkušenost čím by to mohlo být ?, bych bych velmi rád. Nenní důležité program rozchodit, spíše se poučit z chyby.
program v příloze je špatný !!!!