source: EcnlProtoTool/trunk/tcc-0.9.27/tests/tests2/28_strings.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 973 bytes
Line 
1#include <stdio.h>
2#include <string.h>
3
4int main()
5{
6 char a[10];
7
8 strcpy(a, "hello");
9 printf("%s\n", a);
10
11 strncpy(a, "gosh", 2);
12 printf("%s\n", a);
13
14 printf("%d\n", strcmp(a, "apple") > 0);
15 printf("%d\n", strcmp(a, "goere") > 0);
16 printf("%d\n", strcmp(a, "zebra") < 0);
17
18 printf("%d\n", strlen(a));
19
20 strcat(a, "!");
21 printf("%s\n", a);
22
23 printf("%d\n", strncmp(a, "apple", 2) > 0);
24 printf("%d\n", strncmp(a, "goere", 2) == 0);
25 printf("%d\n", strncmp(a, "goerg", 2) == 0);
26 printf("%d\n", strncmp(a, "zebra", 2) < 0);
27
28 printf("%s\n", strchr(a, 'o'));
29 printf("%s\n", strrchr(a, 'l'));
30 printf("%d\n", strrchr(a, 'x') == NULL);
31
32 memset(&a[1], 'r', 4);
33 printf("%s\n", a);
34
35 memcpy(&a[2], a, 2);
36 printf("%s\n", a);
37
38 printf("%d\n", memcmp(a, "apple", 4) > 0);
39 printf("%d\n", memcmp(a, "grgr", 4) == 0);
40 printf("%d\n", memcmp(a, "zebra", 4) < 0);
41
42 return 0;
43}
44
45/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
Note: See TracBrowser for help on using the repository browser.