fork download
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char **argv)
  4. {
  5. int i;
  6.  
  7. char myarray[4];
  8. short secondarray[6];
  9. char *thirdarray[12];
  10.  
  11. printf("Uninitialised arrays:");
  12.  
  13. for (i = 0; i < 4; ++i)
  14. {
  15. printf("myarray[%d] = '%c' or %d\n", i, myarray[i], myarray[i]);
  16. }
  17.  
  18. for (i = 0; i < 6; ++i)
  19. {
  20. printf("secondarray[%d] = %d\n", i, secondarray[i]);
  21. }
  22.  
  23. for (i = 0; i < 12; ++i)
  24. {
  25. printf("thirdarray[%d] = %p\n", i, thirdarray[i]);
  26. }
  27.  
  28. // Loop until newline is read
  29. printf("\n\nPress ENTER to continue...");
  30.  
  31. while (getchar() != '\n') // Loop until we get the newline character from the input
  32. ; // A quick and dirty loop - probably should also check for EOF!
  33.  
  34. printf("\n\n"); // Add some blank lines before the next part
  35.  
  36. {
  37. short shortarray[2] = {4, 1};
  38. char chararray[3] = {'o', 'n', 'e'};
  39.  
  40. long longarray[] = {100000, 5, 543};
  41. char chararray2[] = {'C', '-', 'S', 't', 'r', 'i', 'n', 'g', '\0'};
  42.  
  43. /* sizeof() is an operator which returns the size (in terms of the size of a char) of
  44. * its operand. You can use it on many different things, e.g. arrays (size of array),
  45. * pointers (size of the pointer), basic types, etc. If we have the full array
  46. * declaration, i.e. the name with the [] on it, then we can determine the number of
  47. * elements from the size of the array divided by the size of an element. */
  48.  
  49. for (i = 0; i < (sizeof(shortarray) / sizeof(short)); ++i)
  50. {
  51. printf("shortarray[%d] = %d\n", i, shortarray[i]);
  52. }
  53.  
  54. for (i = 0; i < (sizeof(chararray) / sizeof(char)); ++i)
  55. {
  56. printf("chararray[%d] = '%c' or %d\n", i, chararray[i], chararray[i]);
  57. }
  58.  
  59. for (i = 0; i < (sizeof(longarray) / sizeof(long)); ++i)
  60. {
  61. printf("longarray[%ld] = %d\n", i, longarray[i]);
  62. }
  63.  
  64. for (i = 0; i < (sizeof(chararray2) / sizeof(char)); ++i)
  65. {
  66. printf("chararray2[%d] = '%c' or %d\n", i, chararray2[i], chararray2[i]);
  67. }
  68. }
  69.  
  70. return 0;
  71. }
Time limit exceeded #stdin #stdout 5s 1724KB
stdin
Standard input is empty
stdout
Standard output is empty