我想知道目標c/c中的百分數是多少。在目標c中使用百分號(不是模)
例如:
的printf( 「x等於%d \ n」,x)的;
下面的例子工作...但我想知道如何正確使用所有的%字母。我知道他們也需要處理它是8位,16位,32位或64位。
我想知道目標c/c中的百分數是多少。在目標c中使用百分號(不是模)
例如:
的printf( 「x等於%d \ n」,x)的;
下面的例子工作...但我想知道如何正確使用所有的%字母。我知道他們也需要處理它是8位,16位,32位或64位。
即formatted output,百分號用於開始格式化規範。從給定的鏈路,
%<flags><field width><precision><length>conversion
標誌,場寬度,精度長度的含義,和轉換如下,雖然簡潔。有關更多細節,值得關注標準所說的內容。
標誌
Zero or more of the following: - Left justify the conversion within its field. + A signed conversion will always start with a plus or minus sign. space If the first character of a signed conversion is not a sign, insert a space. Overridden by + if present. # Forces an alternative form of output. The first digit of an octal conversion will always be a 0; inserts 0X in front of a non-zero hexadecimal conversion; forces a decimal point in all floating point conversions even if one is not necessary; does not remove trailing zeros from g and G conversions. 0 Pad d, i, o, u, x, X, e, E, f, F and G conversions on the left with zeros up to the field width. Overidden by the - flag. If a precision is specified for the d, i, o, u, x or X conversions, the flag is ignored. The behaviour is undefined for other conversions.
編輯
正如@stevesliva在評論中提到的,你也可能會發現IOS核心文檔中的String Format Specifiers爲目的C.
應該添加[Objective C reference](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265)as好。 – stevesliva
%
是格式說明符的起始部分。
通常將格式字符串中的字符按字面順序複製到函數的輸出中,就像模板通常那樣,將其他參數渲染到結果文本中以代替某些佔位符 - 由格式說明符標記的點由%
字符,雖然語法不同。寬度,精度,輸出格式都可以做到這一點。
不同類型的格式說明符是可能的,printf
上的任何好的參考都應該詳細說明它們。
謝謝...這幾乎回答了我的問題。我只是想知道百分號的不同類型。即:%d,%a,%o – benpete420
http://www.cplusplus.com/reference/cstdio/printf/或http://en.cppreference.com/w/cpp/io/c/fprintf –
謝謝!這是我需要的。 – benpete420