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

文件编程

发布时间: 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()了

热点内容
单片机android 发布:2024-09-20 09:07:24 浏览:760
如何提高三星a7安卓版本 发布:2024-09-20 08:42:35 浏览:659
如何更换服务器网站 发布:2024-09-20 08:42:34 浏览:306
子弹算法 发布:2024-09-20 08:41:55 浏览:284
手机版网易我的世界服务器推荐 发布:2024-09-20 08:41:52 浏览:812
安卓x7怎么边打游戏边看视频 发布:2024-09-20 08:41:52 浏览:158
sql数据库安全 发布:2024-09-20 08:31:32 浏览:89
苹果连接id服务器出错是怎么回事 发布:2024-09-20 08:01:07 浏览:503
编程键是什么 发布:2024-09-20 07:52:47 浏览:655
学考密码重置要求的证件是什么 发布:2024-09-20 07:19:46 浏览:479