Beginners_-_sizeof_variablesmemory.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "raylib.h"
  2. #include "string.h"
  3. int main(void)
  4. {
  5. // Initialization
  6. //--------------------------------------------------------------------------------------
  7. const int screenWidth = 800;
  8. const int screenHeight = 450;
  9. InitWindow(screenWidth, screenHeight, "raylib example.");
  10. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  11. //--------------------------------------------------------------------------------------
  12. // Main game loop
  13. while (!WindowShouldClose()) // Detect window close button or ESC key
  14. {
  15. // Update
  16. //----------------------------------------------------------------------------------
  17. //----------------------------------------------------------------------------------
  18. // Draw
  19. //----------------------------------------------------------------------------------
  20. BeginDrawing();
  21. ClearBackground(RAYWHITE);
  22. char a[40];
  23. int b=100;
  24. long c=100000;
  25. double d=183.1237d;
  26. float e=2138.234f;
  27. DrawText(FormatText("Size of char = %i",sizeof(a)),100,120,20,BLACK);
  28. DrawText(FormatText("Size of int = %i",sizeof(b)),100,140,20,BLACK);
  29. DrawText(FormatText("Size of long = %i",sizeof(c)),100,160,20,BLACK);
  30. DrawText(FormatText("Size of double = %i",sizeof(d)),100,180,20,BLACK);
  31. DrawText(FormatText("Size of float = %i",sizeof(e)),100,200,20,BLACK);
  32. EndDrawing();
  33. //----------------------------------------------------------------------------------
  34. }
  35. // De-Initialization
  36. //--------------------------------------------------------------------------------------
  37. CloseWindow(); // Close window and OpenGL context
  38. //--------------------------------------------------------------------------------------
  39. return 0;
  40. }