I want to rename file with name of ip address like (192.168.1.55.txt)
In xyz.txt file have ip address.
I m finding this ip address but rename giving problem???
#include <stdio.h>
#include<conio.h>
int main ()
{
int result;
char ipadd[20];
FILE *pFile;;
pFile = fopen ("xyz.txt" , "r");
fseek(pFile,172,SEEK_SET);
fgets (ipadd , 16 , pFile);
printf("Before Rename");
printf("%s",ipadd); // it gives ip address in xyz.txt
char oldname[] ="xyz.txt";
result= rename( oldname , ipadd ); //problem is here
if ( result == 0 )
puts ( "File successfully renamed" );
else
perror( "Error renaming file" );
fclose (pFile);
getch();
}
This gives OutPut:->
Before Rename 192.168.1.55
Error renaming file: Permission denied
How to solve this problem ??