Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use directory names with spaces in C++ language

Shulou Source: shulou.com Published: 2022-06-02 09:42:31 12月03日 Update

This article mainly explains "how to use directory names with spaces in C++ language", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to use directory names with spaces in C++ language".

Copy files with implied or system attributes

Files with implied or system attributes cannot be copied using the copy command provided by the operating system, because the system prompts "File not found" during the copy process. The following Mini Program can solve this problem.

/ / copyfile.c # include $# @ 60; stdio.h $# @ 62; # include $# @ 60; stdlib.h $# @ 62; main (int argc,char * argv []) {if (argc$#@60; 3) {printf ("\ nusage: COPYFILE $# @ 60; source file name $# @ 62; $# @ 60; destination file name $# @ 62;\ n"); exit (1);} copy (argv [1], argv [2]) } copy (char * file1,char * file2) {char ch; FILE * fp1,* fp2; if ((fp1=fopen (file1, "rb")) = = NULL) {printf ("\ nCant open file% s", file1); fclose (fp1); return;} if ((fp2=fopen (file2, "wb")) = = NULL) {printf ("\ nCant open file% s", file2); fclose (fp1); return;} ch=fgetc (fp1) While (! feof (fp1)) {fputc (ch,fp2); ch=fgetc (fp1);} fclose (fp1); fclose (fp2); return;}

Change the name of the subdirectory in any DOS version or windows

DOS only provides a program to change the subdirectory name in version 6. X It is very tedious to change the directory name in windows. The following Mini Program can easily change the name of a subdirectory at any level, and can also be used to change the name of a file

/ / copyfile.c # include $# @ 60; stdio.h $# @ 62; # include $# @ 60; stdlib.h $# @ 62; main (int argc,char * argv []) {if (argc$#@60; 3) {printf ("\ nusage: COPYFILE $# @ 60; source file name $# @ 62; $# @ 60; destination file name $# @ 62;\ n"); exit (1);} copy (argv [1], argv [2]) } copy (char * file1,char * file2) {char ch; FILE * fp1,* fp2; if ((fp1=fopen (file1, "rb")) = = NULL) {printf ("\ nCant open file% s", file1); fclose (fp1); return;} if ((fp2=fopen (file2, "wb")) = = NULL) {printf ("\ nCant open file% s", file2); fclose (fp1); return;} ch=fgetc (fp1) While (! feof (fp1)) {fputc (ch,fp2); ch=fgetc (fp1);} fclose (fp1); fclose (fp2); return;}

Third, use a directory name with spaces

The system uses spaces to distinguish the parameters of the input DOS command, and the same MD, CD, RD and other commands that use DOS cannot use directory names with spaces. However, when the disk is checked with the CHKDSK command, no error message is given for the subdirectory name that contains spaces. This shows that directory names with spaces in DOS are legitimate. Because commands in DOS cannot use directory names with spaces, they can play a role in encryption. The following procedure describes how to use the C++ language to create, enter, and delete subdirectories containing spaces.

/ / copyfile.c # include $# @ 60; stdio.h $# @ 62; # include $# @ 60; stdlib.h $# @ 62; main (int argc,char * argv []) {if (argc$#@60; 3) {printf ("\ nusage: COPYFILE $# @ 60; source file name $# @ 62; $# @ 60; destination file name $# @ 62;\ n"); exit (1);} copy (argv [1], argv [2]) } copy (char * file1,char * file2) {char ch; FILE * fp1,* fp2; if ((fp1=fopen (file1, "rb")) = = NULL) {printf ("\ nCant open file% s", file1); fclose (fp1); return;} if ((fp2=fopen (file2, "wb")) = = NULL) {printf ("\ nCant open file% s", file2); fclose (fp1); return;} ch=fgetc (fp1) While (! feof (fp1)) {fputc (ch,fp2); ch=fgetc (fp1);} fclose (fp1); fclose (fp2); return;} so far, I believe you have a deeper understanding of "how to use directory names with spaces in C++ language". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Spaces directories directory names files commands systems languages categories subdirectories copies programs names file names source files targets facets contents attributes versions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft vpn Redmi Apple OPPO Reno