I need to create a file under the "/Library/Preferences/" Mac directory. But in Lion only root user have write privilege to this dir.
#include <stdio.h>
int main()
{
FILE *fileHandle = NULL;
fileHandle = fopen("/Library/Preferences/v.test", "w");
fclose(fileHandle);
return 0;
}
this line of code works if I run this code as sudo ./a.out
. I wants to do the same programmatically.
Thanks!