Search This Blog

Using System calls in C Program to rename a Directory in Linux

C Program to rename a directory in Unix or Linux operating systems using system call rename().

#include<stdio.h>
main()
{

char s[10],d[10];
printf("Enter source Dir Name:\n");
scanf("%s",s);
printf("Enter New Dir Name:\n");
scanf("%s",d);
if(rename(s,d)==-1)
perror("Can't be changed\n");
else
printf("%s is changed to %s\n\n",s,d);
}

No comments: