c 檔案操作案例字串資料儲存

2021-10-09 22:34:38 字數 2600 閱讀 8321

實現功能

檔案操作方面內容

static list<

string

>

findfile

(string name)

return r;

}//讀取乙個檔案,將其以字串list返回

static

bool

findstring

(string s, list<

string

> ls)

}return

false;}

//檢測list裡有無s

static

bool

findfilestring

(string s)

else}}

return

false;}

//檢測所有資料中有無s

static

void

writefile

(list<

string

> ls,

string name)

//將乙個字串list寫入乙個檔案

完整csharp的類**
class

program

else

break

;case3:

console.

writeline

("請輸入要錄入的資料並回車");

s = console.

readline()

; system.console.

clear()

;addfilestring2

(s);

break

;case4:

console.

writeline

("請輸入要刪除的資料並回車");

s = console.

readline()

; system.console.

clear()

;deletestring

(s);

break

;case5:

console.

writeline

("已退出程式,再見");

b =false

;break

;default

: console.

writeline

("請輸入合法指令");

break;}

}}static

void

directory()

//列印目錄

static list<

string

>

findfile

(string name)

return r;

}//讀取乙個檔案,將其以字串list返回

static

void

writefile

(list<

string

> ls,

string name)

//將乙個字串list寫入乙個檔案

static

bool

findstring

(string s, list<

string

> ls)

}return

false;}

//檢測list裡有無s

static

bool

findfilestring

(string s)

else}}

return

false;}

//檢測所有資料中有無s

static

void

addfilestring1

(string s)

}string st =

"資料/資料"

+(i-1)

+".txt"

; list<

string

> ls =

findfile

(st);if

(ls.count>=

1000

)else

writefile

(ls, st);}

//將字串s寫入資料中,每個檔案限制1000條

static

void

addfilestring2

(string s)

else

}//將字串s寫入資料中,會檢測是否重複,若重複則不寫入

static

void

deletestring

(string s)

else

writefile

(ls, str);}

}}else

}//從資料中刪除s

static

void

display()

else}}

}//列印現有的所有資料

}

使用C語言實現字串逆序操作案例

編寫乙個函式 reverse string char string 實現 將引數字串中的字元反向排列。要求 不能使用c函式庫中的字串操作函式。非遞迴實現 include 編寫乙個函式 reverse string char string 非遞迴實現 實現 將引數字串中的字元反向排列。要求 不能使用c...

c 順序棧基本操作案例(檔案)

順序棧的基本操作 include include using namespace std define ok 1 define error 0 define overflow 2 define maxsize 50 儲存空間的初始分配數量 typedef int status 返回函式狀態值 typ...

shell操作字串案例

str1 name url 中間不能有空格 str2 name url 如果被雙引號包圍,那麼中間可以有空格 str3 name url 中間可以出現別的字串 str4 name url 這樣寫也可以 str5 script index.html 這個時候需要給變數名加上大括號 echo str1 ...