編寫規範C 傳值

2021-06-18 16:26:12 字數 571 閱讀 4424

如果想改變實參的值,用引用或者指標,返回值應與形參型別一致,指標返回指標,引用返回引用

複製物件的操作

class raw2d

3、strcmp的返回值問題:

摘自所在標頭檔案:

string.h

功能:比較字串s1和s2。

一般形式:strcmp(字串1,字串2)

說明:當s1當s1==s2時,返回值= 0

當s1>s2時,返回正數  注意不是1

注:c++ 中

當s1當s1==s2時,返回值等於0

當s1>s2時,返回正數  注意不是1

即:兩個

字串自左向右逐個字元相比(按ascii值大小相比較),直到出現不同的字元或遇'\0'為止。如:

"a"<"b" "a">"a" "computer">"compare"

特別注意:strcmp(const char *s1,const char * s2)這裡面只能比較字串,不能比較數字等其他形式的引數。

if (strcmp(potentialfunction,p1)+1)

C 編寫規範

c 編寫規範 一 兩種命名風格 1.pascal風格 大駝峰命名法 包含乙個到多個單詞,每個單詞首字母大寫,其餘字母均小寫。例如 helloworld setname等等。2.camel風格小駝峰命名法 包含乙個到多個單詞,第乙個單詞首字母小寫,其餘單詞首字母大寫。例如 name productid...

C 傳值和傳位址

1 交換變數x和y的值 void swap int x,int y int temp temp x x y y temp cout int a 5 int b 10 int x 1 int y 2 void swap int x,int y int a 5 int b 10 int x a int ...

C 傳值與傳位址

include struct object 傳值方式 void text1 object a 傳位址方式 void text2 object a int main text1 obj text2 obj return 0 1.傳值方式函式的形參是傳入的實參的乙份拷貝,形參是函式的區域性變數,只在函式...