I think it's like you said and the problem and it's PlayDateOfExam, which suprises me since I'm calling this function all over my code.
The function code is:
char* PlayDateOfExam(int option)
{
char* WaveFileName;
if (option==1)
{
int k=atoi(Global_Input.day);
if (atoi(Global_Input.day)<10)
{
int day=atoi(Global_Input.day);
day=day % 10;
char* day_s=(char*)malloc(sizeof(char)*2);
_itoa(day,day_s,10);
WaveFileName=(char*)malloc(sizeof("\\LowLevel_ASR\\Wave Files\\Grades Files\\"));
strcpy(WaveFileName,"\\LowLevel_ASR\\Wave Files\\Grades Files\\");
strcat(WaveFileName,day_s);
return (WaveFileName);
}
else
{
WaveFileName=(char*)malloc(sizeof("\\LowLevel_ASR\\Wave Files\\Grades Files\\"));
strcpy(WaveFileName,"\\LowLevel_ASR\\Wave Files\\Grades Files\\");
strcat(WaveFileName,Global_Input.day);
return (WaveFileName);
}
}
else if (option==2)
{
int k=atoi(Global_Input.month);
if (atoi(Global_Input.month)<10)
{
int month=atoi(Global_Input.month);
month=month % 10;
char* month_s=(char*)malloc(sizeof(char)*2);
_itoa(month,month_s,10);
WaveFileName=(char*)malloc(sizeof("\\LowLevel_ASR\\Wave Files\\Exams Dates Files\\"));
strcpy(WaveFileName,"\\LowLevel_ASR\\Wave Files\\Exams Dates Files\\");
strcat(WaveFileName,month_s);
return (WaveFileName);
}
else
{
WaveFileName=(char*)malloc(sizeof("\\LowLevel_ASR\\Wave Files\\Exams Dates Files\\"));
strcpy(WaveFileName,"\\LowLevel_ASR\\Wave Files\\Exams Dates Files\\");
strcat(WaveFileName,Global_Input.month);
return (WaveFileName);
}
}
else if (option==3)
{
WaveFileName=(char*)malloc(sizeof("\\LowLevel_ASR\\Wave Files\\Exams Dates Files\\"));
strcpy(WaveFileName,"\\LowLevel_ASR\\Wave Files\\Exams Dates Files\\");
strcat(WaveFileName,"2000+");
return(WaveFileName);
}
else if (option==4)
{
int k=atoi(Global_Input.hour);
if (atoi(Global_Input.hour)<10)
{
int hour=atoi(Global_Input.hour);
hour=hour % 10;
char* hour_s=(char*)malloc(sizeof(char)*2);
_itoa(hour,hour_s,10);
WaveFileName=(char*)malloc(sizeof("\\LowLevel_ASR\\Wave Files\\Grades Files\\"));
strcpy(WaveFileName,"\\LowLevel_ASR\\Wave Files\\Grades Files\\");
strcat(WaveFileName,hour_s);
return (WaveFileName);
}
else
{
WaveFileName=(char*)malloc(sizeof("\\LowLevel_ASR\\Wave Files\\Grades Files\\"));
strcpy(WaveFileName,"\\LowLevel_ASR\\Wave Files\\Grades Files\\");
strcat(WaveFileName,Global_Input.hour);
return (WaveFileName);
}
}
else if (option==5)
{
int k=atoi(Global_Input.minute);
if (atoi(Global_Input.minute)<10)
{
int minute=atoi(Global_Input.minute);
minute=minute % 10;
char* minute_s=(char*)malloc(sizeof(char)*2);
_itoa(minute,minute_s,10);
WaveFileName=(char*)malloc(sizeof("\\LowLevel_ASR\\Wave Files\\Grades Files\\"));
strcpy(WaveFileName,"\\LowLevel_ASR\\Wave Files\\Grades Files\\");
strcat(WaveFileName,minute_s);
return (WaveFileName);
}
else
{
WaveFileName=(char*)malloc(sizeof("\\LowLevel_ASR\\Wave Files\\Grades Files\\"));
strcpy(WaveFileName,"\\LowLevel_ASR\\Wave Files\\Grades Files\\");
strcat(WaveFileName,Global_Input.minute);
return (WaveFileName);
}
}
else if (option==6)
{
WaveFileName=(char*)malloc(sizeof("\\LowLevel_ASR\\Wave Files\\Exam Locations Files\\"));
strcpy(WaveFileName,"\\LowLevel_ASR\\Wave Files\\Exam Locations Files\\");
strcat(WaveFileName,Global_Input.class_location);
return (WaveFileName);
}
else if (option==7)
{
WaveFileName=(char*)malloc(sizeof("\\LowLevel_ASR\\Wave Files\\Exam Locations Files\\"));
strcpy(WaveFileName,"\\LowLevel_ASR\\Wave Files\\Exam Locations Files\\");
strcat(WaveFileName,Global_Input.class_number);
return (WaveFileName);
}
return ("Error");
}
The call to the function is:
sndPlaySound(PlayDateOfExam(4),SND_SYNC);
which is written in a thread that is running.
I don't know why in this segment of the code it crashes