69,382
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
void main(void)
{
printf("enter a mane:\n");
char a;
scanf("%c",&a);
FILE *Fprintf;
Fprintf = fopen("c:\test\1.txt", "w");
return;
}
#include <stdio.h>
#include <string.h>
void main(void)
{
char a[256];
FILE *f;
printf("Enter path for 1.txt:\n");
fgets(a,256,stdin);
if ('\n'==a[strlen(a)-1]) a[strlen(a)-1]=0;
if ('\\'!=a[strlen(a)-1]) strcat(a,"\\");
strcat(a,"1.txt");
f = fopen(a, "w");
//...
fclose(f);
return;
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void main(void)
{
char a[256];
char cmd[512];
FILE *f;
printf("Enter a path for list all files:\n");
fgets(a,256,stdin);
if ('\n'==a[strlen(a)-1]) a[strlen(a)-1]=0;
if ('\\'!=a[strlen(a)-1]) strcat(a,"\\");
sprintf(cmd,"dir \"%s*.*\" /b /s /a-d >d:\\allfiles.txt",a);
system(cmd);
f = fopen("d:\\allfiles.txt", "r");
if (NULL==f) return;
while (1) {
if (NULL==fgets(cmd,512,f)) break;
printf("%s",cmd);
}
fclose(f);
return;
}
# include <stdio.h>
int main()
{
char filename[BUFSIZ];
printf("enter a file name: ");
scanf("%s", filename);
printf("%s\n", filename);
return 0;
}
enter a file name: C:\test\1.txt
C:\test\1.txt