以下三條輸出語句分別輸出什麼?

2022-05-09 17:28:59 字數 868 閱讀 2626

char

str1 ="

abc"

;char

str2="

abc"

;const

char

str3 ="

abc"

;const

char

str4 ="

abc"

;const

char

*str5="

abc"

;const

char

*str6="

abc"

;cout

<<

boolalpha

<<

( str1

==str2 )

<<

endl;

//輸出什麼?

cout

<<

boolalpha

<<

( str3

==str4 )

<<

endl;

//輸出什麼?

cout

<<

boolalpha

<<

( str5

==str6 )

<<

endl;

//輸出什麼?

false

false

true

答:分別輸出false,false,true。str1和str2都是字元陣列,每個都有其自己的儲存區,它們的值則是各儲存區首位址,不等;str3和str4同上,只是按const語義,它們所指向的資料區不能修改。str5和str6並非陣列而是字元指標,並不分配儲存區,其後的「abc」以常量形式存於靜態資料區,而它們自己僅是指向該區首位址的指標,相等。

以下兩條輸出語句分別輸出什麼?

float a 1.0f cout int a endl cout int a endl cout boolalpha int a int a endl 輸出什麼?float b 0.0f cout int b endl cout int b endl cout boolalpha int b in...

三條常用的sql語句

定義 表和表之間的資料以縱向的方式連線在一起。之前的內連線,外連線都是以橫向的方式連線在一起 注意,union 內部的每個 select 語句必須擁有相同數量的列。列也必須擁有相似的資料型別。同時,每個 select 語句中的列的順序必須相同。sql union 語法 select column n...

Ruby 學習(三)條件語句

語法 if conditional then code.elsif conditional then code.else code.end debug 1 print debug n if debug如果conditional為假,則執行code var 1 print 1 這一行輸出 n if v...