Add filename test
This commit is contained in:
parent
3fbc25028c
commit
b73e6fbf49
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_project_file>
|
||||||
|
<FileVersion major="1" minor="6" />
|
||||||
|
<Project>
|
||||||
|
<Option title="filename_test" />
|
||||||
|
<Option pch_mode="2" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Build>
|
||||||
|
<Target title="Debug">
|
||||||
|
<Option output="bin/Debug/filename_test" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Debug/" />
|
||||||
|
<Option type="1" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-g" />
|
||||||
|
</Compiler>
|
||||||
|
</Target>
|
||||||
|
<Target title="Release">
|
||||||
|
<Option output="bin/Release/filename_test" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Release/" />
|
||||||
|
<Option type="1" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-O2" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="-s" />
|
||||||
|
</Linker>
|
||||||
|
</Target>
|
||||||
|
</Build>
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-Wall" />
|
||||||
|
<Add option="-fexceptions" />
|
||||||
|
</Compiler>
|
||||||
|
<Unit filename="main.cpp" />
|
||||||
|
<Extensions />
|
||||||
|
</Project>
|
||||||
|
</CodeBlocks_project_file>
|
|
@ -0,0 +1,5 @@
|
||||||
|
# depslib dependency file v1.0
|
||||||
|
1609576207 source:/root/filename_test/main.cpp
|
||||||
|
<iostream>
|
||||||
|
<cstdio>
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
typedef void(*pfun)();
|
||||||
|
|
||||||
|
void dale(){
|
||||||
|
printf("custom filename test by daleclack\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void write1(){
|
||||||
|
getchar();
|
||||||
|
char str[57];
|
||||||
|
fgets(str,sizeof(str),stdin);
|
||||||
|
freopen("test","w",stdout);
|
||||||
|
printf("%s",str);
|
||||||
|
fclose(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test(){
|
||||||
|
char filename[57];
|
||||||
|
FILE *fp;
|
||||||
|
fp=fopen("test","r");
|
||||||
|
if(fp==NULL){printf("File not exist!");return ;}
|
||||||
|
fgets(filename,57,fp);
|
||||||
|
fclose(fp);
|
||||||
|
int length=strlen(filename);
|
||||||
|
filename[length-1]='\0';
|
||||||
|
fp=fopen(filename,"w");
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
pfun a[]={dale,write1,test};
|
||||||
|
|
||||||
|
int main(int argc,char *argv[])
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
printf("1.write content 2.test the custom filename\n");
|
||||||
|
scanf("%d",&x);
|
||||||
|
a[x]();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
5465263
|
Loading…
Reference in New Issue