c 字串常用操作

2021-06-07 08:20:38 字數 752 閱讀 2565

class class1

}//trim方法,刪除字串中的空格或其它字元

string stre = stra.trim();

console.writeline ("stre: "+stre);

//使用/顯示引號"和反斜線/

string strf = "c://windows//system32//";

console.writeline ("/"" + strf + "/"");

//使用@顯示引號"和反斜線/

string strg = @"c:/windows/system32/";

console.writeline (@"""" + strg + @"""");

//string轉換為int型

string strh = "12345";

int theint = int.parse (strh);

console.writeline ("科學計數顯示整數",theint);

console.writeline ("十六進製制顯示整數",theint);

//string轉換為float型

string stri = "123.45";

float thefloat = float.parse (stri);

console.writeline ("顯示浮點數,指定小數字數",thefloat);

console.readline();}}

}

c 常用的字串操作

int atoi const char str 函式char numstr 12 int val atoi numstr 標頭檔案 stdlib.h stdio.h char strtok char str,const char delim 分解字串str為一組字串,delim為分隔符。char s...

字串常用操作。。。

include include include char itoa int value result char malloc sizeof char i 1 for j 0 jint i 65 char p itoa i printf s n p free p p null include incl...

字串常用操作

coding utf 8 import string1 判斷str unicode字串物件 def isastring anobj return isinstance anobj,basestring basesting是str,unicode的父類 defisaint anobj return i...