Hi everyon, I need to open a file, and if it doesn't exist, make a new one wieth a long value as its name. I found that I can use the Open() function, but I'm having problems with using the correct path.
I want to put the new file or access it from DIR_BANK, and add the SUF_BANK extension to it; both of which are declared in a helper file.
Here is a part of my code, when I try to execute my program, I get the following error: "No such file or directory"
Can you please help me out?
I have commented out all the different paths I tried!
Thanks in advance,
Mike
Code:
int openOrCreateAcct (int * const acctFd, const unsigned long acctNum)
{
int fd;
// const char *path = '"%s%u%s", DIR_BANK, acctNum, SUF_BANK';
//const char *path = "bankPro/acctNum.cct";
//const char *path = "DIR_BANK/acctNum.SUF_BANK"; //want this!
if (*acctFd = (fd = open(path, "O_CREAT", "r+")) < 0)
{
*acctFd = -1;
perror("Open failed");
exit(2);
}
.
.
.