hi,
I am trying delete an old txt file and rename the new modified txt file... i followed everything from the example. However, i can't successfully rename the file. deletion is ok though. thank you.

void save(Name inName[], int j)
	{
		ofstream writer;
		writer.open("save.txt");

		for(int x=0; x<j; x++)
		{
			writer<<inName[x].getID()<<"\n"<<inName[x].getLastName()<<
"\n"<<inName[x].getFirstName()<<"\n"<<inName[x].getPhone()
<<"\n"<<inName[x].getAmt()<<"\n";
		}

		int resultRemove = remove("names.txt");
		if(resultRemove==0)
		{
			puts("removed");
		}

		else
		{
			perror("error");
		}

		int resultRename;

		char oldName[]= "save.txt";
		char newName[] = "names.txt";

		resultRename = rename(oldName, newName);

		if(resultRename==0)
		{
			puts("good");
		}

		else
		{
			perror("error");
		}

	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.