int main(int argc, char* argv[])
{
FILE *pfd;//will get the file we are gone read from
char fileName[40];//get files name
char line[1024];
FILE *simulate;//will get the file we are gone read from
char line2[1024];
int arrSize=argc-2;
station * stations=(station *)malloc(sizeof(station)*(arrSize));//intilzing ther array
int i=2;//Auxiliary variable for the first for loop-reads information from all fiels
int j=0; //Auxiliary variable to help as clean the memory
ClientsLinkedList* data;
Link * temp;//temp varbale to help us clean the memory
Link * tempNext;
if(stations==NULL)
{
printf("Failed to allocate memory");
}
for(i;i<argc;i++)
{
data=CreateClientsLinkedList();
stations[i].m_clients=*data;
strcpy(fileName,argv[i]);
///* Open the file. If NULL is returned there was an error */
if((pfd = fopen("station.txt" , "r")) == NULL)
{
printf("Error Opening File.\n");
}
while(fgets(line, sizeof(line), pfd) != NULL)
{
ReadByCharName(line,stations,i);
}
fclose(pfd); /* Close the file */
}
////************************************************reading from simulation file*******************************************
/*** Open the file. If NULL is returned there was an error */
if((simulate = fopen("simulation.txt", "r")) == NULL)
{
printf("Error Opening File.\n");
}
while(fgets(line, sizeof(line2), simulate) != NULL)
{
ReadSimulation(line2,arrSize,stations);
}
fclose(simulate); /* Close the file */
////*********************************************clening memory****************************************
for(j;j<arrSize;j++)
{
temp=stations[j].m_clients.m_head;
while(temp!=NULL)
{
tempNext=temp->m_next;
free(temp);
temp=tempNext;
}
}
free(stations);
return 0;
}
Это основная наша программа, которая позволяет получить один файл для моделирования и не знать количество файлов станций и инициализировать структуру данных из них. , но когда мы пытаемся запустить проект, мы получаем сообщение об ошибке «Debug Assertion Failed». , пожалуйста, если вы можете помочь нам решить проблему, нам необходимо отправить проект в воскресенье.Ошибка отладки в Visual Studio c
спасибо!
Пожалуйста, прекратите писать код. Если вы просите о помощи по простому вопросу о домашнем задании, а ваш класс intro использует C, вы будете обязаны к неудаче. –
@Conrad: В мой класс введена C. Это было здорово. В моей школе специальности майора должны были взять C. CS - единственный, кто использовал java. – Falmarri