Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String Fortran:如何从字符中删除文件扩展名_String_Fortran_Character - Fatal编程技术网

String Fortran:如何从字符中删除文件扩展名

String Fortran:如何从字符中删除文件扩展名,string,fortran,character,String,Fortran,Character,我有一个Fortran代码,要求用户输入文件名。代码处理该文件,我想根据原始文件名写出另一个文件。我想,如果我能理解如何删除文件扩展名,那么我就可以将任何我想要的连接到末尾 如何去掉字符中的文件扩展名 字符(len=256)::输入文件,输出文件 原始文件:AnyName.xxx 输出文件:AnyName_Output.csv您可以使用scan定位字符串输入文件中最后一个点的位置。然后可以使用该位置提取不带扩展名的输入_文件并连接新文件 character(len=256):: input_fi

我有一个Fortran代码,要求用户输入文件名。代码处理该文件,我想根据原始文件名写出另一个文件。我想,如果我能理解如何删除文件扩展名,那么我就可以将任何我想要的连接到末尾

如何去掉字符中的文件扩展名

字符(len=256)::输入文件,输出文件

原始文件:AnyName.xxx


输出文件:AnyName_Output.csv

您可以使用
scan
定位字符串输入文件中最后一个点的位置。然后可以使用该位置提取不带扩展名的输入_文件并连接新文件

character(len=256):: input_file, output_file
integer :: ppos
character(len=3)  :: new_ext="csv"

ppos = scan(trim(input_file),".", BACK= .true.)
if ( ppos > 0 ) output_file = input_file(1:ppos)//new_ext

您可以使用
scan
查找字符串输入文件中最后一个点的位置。然后可以使用该位置提取不带扩展名的输入_文件并连接新文件

character(len=256):: input_file, output_file
integer :: ppos
character(len=3)  :: new_ext="csv"

ppos = scan(trim(input_file),".", BACK= .true.)
if ( ppos > 0 ) output_file = input_file(1:ppos)//new_ext