|
|
C LINUX how to achieve functional copy of the document?
|
|
The C Programming Linux beginner. This function does not know how to achieve? What specific knowledge to use?
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
System
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
May open two descriptors, a read (), another write (), would not achieve!
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
Say the details? I just portal, and many unclear ah. For example, the first category of documents : :
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
Provide an example for you to see, I was not very proficient in : I hope you can understand
#include "Stdio.h> #include "String.h> #include "Assert.h> #include "Sys/types.h> #include "Sys/stat.h> #inlcude "Fcntl.h>
Int copy_file (char *form, char *to) {
Int form_fd, to_fd; Char ch = '\0'; Int with officers = 0
Assert (form> NULL); Assert (to> NULL); Form_fd to_fd = 0 = 0
Form_fd = open (form, O_RDONLY); If (form_fd "0) Return 1; To_fd = open (to, O_RDONLY); If (to_fd "0) Return 1; If (to_fd "0) {
Close (to_fd); Return 1; }
To_fd = open (to, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); If (to_fd "0) Return 1;
While (0) {
With officers = read (form_fd, &ch, 1); If (with officers of the "0) Return 1; If (with officers ====== 0) Break; Write (to_fd, &ch, 1); }
Close (form_fd); Close (to_fd);
Return 0 }
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
C Bible buy the bar, you have to have all the above, a little basic work. Today interview for the gang, which alone of this question, !@#$%^&
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
I suggest you look at the books or more, such as c language portal type of books, so many procedures can be found.
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
I suggest u use "int link (const char *oldpath, const char *newpath); "
See details man link :
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
You find a serious look at the book and COPY What is the difference between LINK This is your conceptual quote
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
Thank you! Well, if I want to add a Linux system call, the system transfer function is to copy files, what ways ah? Calling in another procedure like how the new system call?
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
See numerous articles on what you found in a system call to increase the KERNEL
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
I used this procedure successfully translated (Of course, it is a typo include--inlcude), but has no operating results, please! Functional copies of the guidance can not be achieved!
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
You program named test.c Gcc test.c
. /a.out Input-file-name output-file-name
Will be OK!
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
Tried, but no matter how operations are not the desired results. Canada trails were not complicated and are not the objectives of paper trails. The interview
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
I tried, no problem. Operating procedure when you have advice?
|
|
|
Re : How to achieve the Linux C functional copy of the document?
|
|
No suggested. For instance, under a document called hello.c in /pub/program I operation. /copy.out /pub/program/hello.c /pub/program/aa.c Results have nothing.
|