当前位置:首页 » 编程软件 » 文件编程

文件编程

发布时间: 2022-01-08 11:09:42

‘壹’ c#关于文件编程

先加入命名空间
using System.IO;
using System.Text;

public void bind()
{
string aaa = GetInterIDList("自己就是一座宝藏—陈安之.txt");
char[] dot = new char[4] { ',', '?', '。', '!' };//你要分割的标点符号
string[] haha = aaa.Split(dot);
foreach (string str in haha)
{
Console.WriteLine(str);
}
}
public string GetInterIDList(string strfile)
{
string strout="";
if (!File.Exists(System.Web.HttpContext.Current.Server.MapPath(strfile)))//你要获取的文件的虚拟路径
{

}
else
{
StreamReader sr = new StreamReader(System.Web.HttpContext.Current.Server.MapPath(strfile), System.Text.Encoding.Default);
String input = sr.ReadToEnd();
sr.Close();
strout = input;
}
return strout;
}

在主函数里面调用bind();就可以了
希望以上的回答对你有所帮助!!!

‘贰’ C语言文件编程

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int x;
char s[200];
FILE *fin, *fout;

if((fin = fopen("file1.dat", "r")) == NULL)
{
exit(0);
}
if((fout = fopen("file2.dat", "w")) == NULL)
{
exit(0);
}

do
{
x = fscanf(fin, "%s", s);
fprintf(fout, "%s", s);
}while(x > 0);

fclose(fin);
fclose(fout);

return 0;
}

‘叁’ C语言编程关于文件方面

#include<stdio.h>
#include<string.h>
void main()
{
int i,j;
char temp;
char s[11];
FILE *pf=fopen("c:\\dos\\a.dat","r");
fgets(pf,11,pf);
for(i=0;i<9;i++)
{
for(j=0;j<9-i;j++)
{
if(s[j]>s[j+1])
{
temp=s[j];
s[j]=s[j+1];
s[j+1]=temp;
}
}

}

}

‘肆’ C语言中,如何用多个文件编写程序

将一个函数写在一个文件里,然后再在另一个文件里用“include”包含这个文件。举个例子 在文件c1.c里编一个函数:
void printWord(){
printf("Hello!world!");
}
再建立一个文件c2.c,文件开头写上#include"c1.c",就可以调用c1.c里的函数printword()了

热点内容
安卓如何设置手机充电 发布:2025-04-27 06:10:24 浏览:588
猿编程ap 发布:2025-04-27 06:09:47 浏览:431
华为服务器上如何装虚拟化软件 发布:2025-04-27 06:09:38 浏览:633
c连接sqlserver数据库 发布:2025-04-27 06:02:56 浏览:369
光猫配置页面有哪些 发布:2025-04-27 06:02:08 浏览:712
js获取上传图片的大小 发布:2025-04-27 06:02:05 浏览:623
百度云解压码破解 发布:2025-04-27 06:00:31 浏览:855
算法工程师怎么考 发布:2025-04-27 05:51:15 浏览:953
算法十进制十六进制 发布:2025-04-27 05:51:07 浏览:253
linux系统及应用 发布:2025-04-27 05:35:16 浏览:374