當前位置:首頁 » 編程軟體 » 文件編程

文件編程

發布時間: 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-09-06 20:59:35 瀏覽:127
抖音安卓為什麼發不了圖集 發布:2025-09-06 20:50:25 瀏覽:554
simd編程 發布:2025-09-06 20:49:40 瀏覽:450
藍色伺服器怎麼查故障 發布:2025-09-06 20:31:02 瀏覽:886
華為開機怎麼有安卓 發布:2025-09-06 20:05:36 瀏覽:425
拍攝女性題材腳本 發布:2025-09-06 19:51:23 瀏覽:961
clay伺服器ip 發布:2025-09-06 19:46:53 瀏覽:647
linuxmysql恢復 發布:2025-09-06 19:44:37 瀏覽:354
我的世界伺服器跑酷43 發布:2025-09-06 19:42:48 瀏覽:442
linux的grep命令 發布:2025-09-06 19:38:13 瀏覽:388