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

文件編程

發布時間: 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 瀏覽:759
如何提高三星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 瀏覽:653
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:477