55-char-array.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. *
  5. * This file is part of GNU Mes.
  6. *
  7. * GNU Mes is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * GNU Mes is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <string.h>
  21. #include <mes/lib-mini.h>
  22. char g_hello[] = "hello\n" "world\n";
  23. char *g_hello2 = "hello\n" "world\n";
  24. char g_hello3[] = {
  25. 'h', 'e', 'l', 'l', 'o', '\n',
  26. 'w', 'o', 'r', 'l', 'd', '\n',
  27. '\0',
  28. }
  29. ;
  30. int g_hello_int[] = { 0, 1, 2, 3, 4, 5 };
  31. int
  32. main (int argc)
  33. {
  34. oputs ("0:"); oputs (g_hello); oputs ("\n");
  35. oputs ("2:"); oputs (g_hello2); oputs ("\n");
  36. oputs ("3:"); oputs (g_hello3); oputs ("\n");
  37. if (strcmp (g_hello, g_hello2))
  38. return 1;
  39. if (strcmp (g_hello, g_hello3))
  40. return 2;
  41. char hello[] =
  42. "hello\n"
  43. "world\n"
  44. ;
  45. char *hello2 =
  46. "hello\n"
  47. "world\n"
  48. ;
  49. oputs (hello);
  50. oputs (hello2);
  51. if (strcmp (hello, hello2))
  52. return 3;
  53. char hello3[] =
  54. {
  55. 'h', 'e', 'l', 'l', 'o', '\n',
  56. 'w', 'o', 'r', 'l', 'd', '\n',
  57. '\0',
  58. }
  59. ;
  60. oputs (hello3);
  61. if (strcmp (hello, hello3))
  62. return 4;
  63. if (g_hello_int[0])
  64. return 5;
  65. if (g_hello_int[1] != 1)
  66. return 6;
  67. int hello_int[] = {0, 1, 2, 3, 4, 5};
  68. if (hello_int[0])
  69. return 7;
  70. if (hello_int[1] != 1)
  71. return 8;
  72. return 0;
  73. }