hi all
i want to open a file but this file in other directory.and i want to use this function:

int  open(  char  *filename,  int  access,  int  permission  );

i can not use other function, because i have use only system call function.

when file exists beside of my code, there isn't problem. but when exist in other drectory can not open that.

Recommended Answers

All 5 Replies

Give the complete path in the parameter filename.

i did it , but not works correctly.

Ah, you haven't turned your PC on. The power is off.

Oh, you say the power is already on? Well, I guess my psychic ability to guess what your problem is must be broken. I'm afraid you're going to have to describe the problem to us.

Can you be more specific? What didn't work? What was the path you were trying to use? What kind of error did it return?

ALso, can you give us the OS you are running under? The open() function you describe is primarily a Unix/Linux system call, though there are versions of it that have been ported to DOS and Windows. If you are running under the latte, there may be issues with how it handles pathnames, especially if you are using a DOS compiler (such as Turbo C) under a Windows system.

BTW, do you know why your instructor wants you to use this function? It's a rather unusual requirement, and it might shed some light on it if we knew the reason why.

With reference to ur query,
FILEfp;
int fopen(fp,char
filename,"w");
fp is FILE*, char*filename is filepath, w is file mode i.e., read, write, read and write.

commented: With reference to your repeated failure to read the actual query, please read the actual query before offering useless answers. -3
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.