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

文件編程

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

熱點內容
java經典教程完整版 發布:2025-04-26 23:43:22 瀏覽:381
怎麼給蘋果簡訊加密 發布:2025-04-26 23:43:21 瀏覽:724
雲與伺服器安全bg什麼意思 發布:2025-04-26 23:43:21 瀏覽:264
mc基岩版伺服器搭建方法 發布:2025-04-26 23:43:10 瀏覽:367
現代名圖車載大屏出廠密碼是多少 發布:2025-04-26 23:42:28 瀏覽:495
小說資料庫 發布:2025-04-26 23:36:33 瀏覽:870
我的世界伺服器隱藏ID插件 發布:2025-04-26 23:28:35 瀏覽:771
c語言給指針分配內存 發布:2025-04-26 23:20:20 瀏覽:117
普通的安卓數據線叫什麼名 發布:2025-04-26 23:19:05 瀏覽:108
上海長江存儲有廠房嗎 發布:2025-04-26 23:08:18 瀏覽:894