Что сделать чтоб параметры передавались с командной строки??? Подскажите пожалуста
| Код | void main(int argc, char* argv[]) { int src, dst, size; char buf[BUF_SIZE]; char *dstFile = (char*) malloc(MAXPATH); char *sourceFile = (char*) malloc(MAXPATH);
{ int i =0; printf ("\n"); // printf ("You have decided to copy a file.\nPrint the full path to file which you want to copy.\nExample: C:\134boot.ini\n"); scanf("%s", sourceFile); //printf ("\n"); if((src = _open(sourceFile, _O_BINARY | _O_RDONLY))==-1) { perror("Copy error"); exit(1); } printf ("Now print the path to the place where you want to copy your file and its name.\nExample: D:\134boot.txt\n"); scanf("%s", dstFile); printf ("\n"); int a = 1; int err3 = 0; if((dst = _open(dstFile, _O_BINARY | _O_CREAT | _O_RDWR ))==-1) { perror("Create file error"); exit(1); } while(!_eof(src)) { i++; if( ( size = _read( src, buf, BUF_SIZE ) ) == -1 ) { perror("Read error"); break; } else { printf ("block " "%d",i); printf(" read successful\n"); } if( err3 = _write( dst, buf, size ) == -1 ) { perror("Write error"); break; } else { printf ("block " "%d",i); printf (" write successful\n"); } } if (err3 != 1) printf ("File copy OK!\n"); _close(dst);
if (err3 != 0) { int err = 0; if((err = remove(dstFile))==-1) { perror("Delete file error"); } else printf ("File was deleted!\n"); } _close(src); } }
|
|