I made the changes but still it gives the error, unless again I am missing something. Here is what it looks like with all the changes:
Code:
void changename()
{
fin.open(profilename);
if(fout.fail())
{
printf("Error, Returning to main menu");
menu();
}
while(!fin.eof())
{
system("cls");
i=0;
for(i = 0; i < 500; i++)
{
szEdit[i] = new char[256];
}
fin.getline(buffer, 256);
strcpy(szEdit[i], buffer);
if (stricmp(fcontact, szEdit[i]) == 0)
{
fin.close();
j = i;
system("cls");
printf("Contact found!");
Sleep(1500);
system("cls");
printf("Enter the new name: ");
cin >> name;
strcat(econtact, name);
strcpy(name, econtact);
strcpy(szEdit[j], name);
fin.close();
fin.open(profilename);
if(fout.fail())
{
printf("Error, Returning to main menu");
menu();
}
while(!fin.eof())
{
i = 0;
fin.getline(szEdit[i], 256);
i++;
}
k = i;
strcpy(szEdit[j], name);
fin.close();
fout.open(profilename);
if(fout.fail())
{
printf("Error, Returning to main menu");
menu();
}
while(i<=k)
{
i = 0;
fout << szEdit[i];
i++;
}
//system("cls");
printf("Editing complete!");
fout.close();
Sleep(1500);
}
else
{
i++;
}
}
}