1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
Escape sequences:
printf("tab:\t:")
printf("newline:\n:")
printf("return:\r:")
printf("formfeed:\f:")
printf("backspace:\b:")
printf("alarm:\a:")
printf("escape:\e:")
printf("backslash:\\:")
printf("double quote:\":")
Numbers, strings and chars:
printf("%% \t a percent sign")
printf("%c \t a character with the given number", 50)
printf("%s \t a string", "This is a string, \"a very good string\"")
printf("%d \t a signed integer, in decimal", -3)
printf("%u \t an unsigned integer, in decimal", 3)
printf("%o \t an unsigned integer, in octal", 9)
printf("%x \t an unsigned integer, in hexadecimal", 17)
printf("%e \t a floating-point number, in scientific notation", 3.141)
printf("%f \t a floating-point number, in fixed decimal notation", 3.141)
printf("%g \t a floating-point number, in best notation", 3.141)
printf("decimal: %d, float: %f", 3.141, 4)
printf("decimal padded: %03d, float precision: %0.2f", 3.141, 4)
Special chars in strings:
printf("Can't work")
printf("Can't work, won't work")
printf("Open bracket(")
printf("Open bracket( and close bracket)")
printf("Open bracket( and close bracket)")
printf("macro's gone" (ba"n)'(a"nas))
Case:
toupper(CoNvErT Me To UpPeR cAsE)
tolower(CoNvErT Me To LoWeR cAsE)
toupperfirst(coNvErT My FiRsT cHaR tO uPpPeR cAsE)
tolowerfirst(CoNvErT My FiRsT cHaR tO lOwEr CaSe)
Substing:
substr(test string, 2)
substr(test string, 0, 6)
substr(test string, 2, 6)
|