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

文件編程

發布時間: 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()了

熱點內容
curlc上傳 發布:2025-07-04 09:59:35 瀏覽:881
沒有編譯器能運行c程序嗎 發布:2025-07-04 09:54:38 瀏覽:307
創建配置目錄錯誤是什麼意思 發布:2025-07-04 09:53:35 瀏覽:48
為什麼租憑伺服器不能玩了 發布:2025-07-04 09:03:01 瀏覽:984
安卓手機減肥軟體哪個好 發布:2025-07-04 08:51:17 瀏覽:997
Oracle查看資料庫歸檔 發布:2025-07-04 08:44:53 瀏覽:608
950買什麼配置好 發布:2025-07-04 08:39:39 瀏覽:611
怎樣給應用加密 發布:2025-07-04 08:38:41 瀏覽:458
python的注釋符號 發布:2025-07-04 08:29:19 瀏覽:129
守望領域門禁密碼是多少 發布:2025-07-04 08:16:22 瀏覽:333