[ create a new paste ] login | about

Link: http://codepad.org/QVX3QPat    [ raw code | output | fork ]

C, pasted on Sep 11:
/*
 * A program that illustrates strings in C.  Designed for C99, but should run
 * fine in C90 with a lot of warnings.
 */

#include <stdio.h>
#include <string.h>
#include <wchar.h>

char *s1 = "abd中日";
wchar_t *s2 = L"abd中日";

int main() {
    int i, n;
    printf("length of s1 is %d\n", strlen(s1));
    printf("length of s2 using wcslen is %d\n", wcslen(s2));
    printf("The codepoints of the characters of s2 are\n");
    for (i = 0, n = wcslen(s2); i < n; i++) {
        printf("%02x\n", s2[i]);
    } 
    return 0;
}


Output:
1
2
3
4
5
6
7
8
length of s1 is 9
length of s2 using wcslen is 5
The codepoints of the characters of s2 are
61
62
64
4e2d
65e5


Create a new paste based on this one


Comments: