Rev 1271 | Rev 1735 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1271 | Rev 1604 | ||
---|---|---|---|
Line 30... | Line 30... | ||
30 | 30 | ||
31 | #define BUFFER_SIZE 32 |
31 | #define BUFFER_SIZE 32 |
32 | 32 | ||
33 | void test(void) |
33 | void test(void) |
34 | { |
34 | { |
- | 35 | int retval; |
|
35 | __native nat = 0x12345678u; |
36 | __native nat = 0x12345678u; |
36 | 37 | ||
37 | unsigned char buffer[BUFFER_SIZE]; |
38 | char buffer[BUFFER_SIZE]; |
38 | 39 | ||
39 | printf(" Printf test \n"); |
40 | printf(" Printf test \n"); |
40 | 41 | ||
41 | printf(" text 10.8s %*.*s \n", 5, 3, "text"); |
42 | printf(" text 10.8s %*.*s \n", 5, 3, "text"); |
42 | printf(" very long text 10.8s %10.8s \n", "very long text"); |
43 | printf(" very long text 10.8s %10.8s \n", "very long text"); |
Line 50... | Line 51... | ||
50 | 51 | ||
51 | printf("'%#llx' 64bit, '%#x' 32bit, '%#hhx' 8bit, '%#hx' 16bit, __native '%#zX'. '%#llX' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, nat, 0x1234567887654321ull, "Lovely string" ); |
52 | printf("'%#llx' 64bit, '%#x' 32bit, '%#hhx' 8bit, '%#hx' 16bit, __native '%#zX'. '%#llX' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, nat, 0x1234567887654321ull, "Lovely string" ); |
52 | 53 | ||
53 | printf(" Print to NULL '%s'\n",NULL); |
54 | printf(" Print to NULL '%s'\n",NULL); |
54 | 55 | ||
- | 56 | retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters."); |
|
- | 57 | printf("Result is: '%s', retval = %d\n", buffer, retval); |
|
- | 58 | ||
- | 59 | retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters."); |
|
- | 60 | printf("Result is: '%s', retval = %d\n", buffer, retval); |
|
- | 61 | ||
55 | printf("Print short text to %d char long buffer via snprintf.\n", BUFFER_SIZE); |
62 | printf("Print short text to %d char long buffer via snprintf.\n", BUFFER_SIZE); |
56 | snprintf(buffer, BUFFER_SIZE, "Short %s", "text"); |
63 | retval = snprintf(buffer, BUFFER_SIZE, "Short %s", "text"); |
57 | printf("Result is: '%s'\n", buffer); |
64 | printf("Result is: '%s', retval = %d\n", buffer, retval); |
58 | 65 | ||
59 | printf("Print long text to %d char long buffer via snprintf.\n", BUFFER_SIZE); |
66 | printf("Print long text to %d char long buffer via snprintf.\n", BUFFER_SIZE); |
60 | snprintf(buffer, BUFFER_SIZE, "Very long %s. This text`s length is more than %d. We are interested in the result.", "text" , BUFFER_SIZE); |
67 | retval = snprintf(buffer, BUFFER_SIZE, "Very long %s. This text`s length is more than %d. We are interested in the result.", "text" , BUFFER_SIZE); |
61 | printf("Result is: '%s'\n", buffer); |
68 | printf("Result is: '%s', retval = %d\n", buffer, retval); |
62 | 69 | ||
63 | return; |
70 | return; |
64 | } |
71 | } |