-
Notifications
You must be signed in to change notification settings - Fork 10
/
Beginners_-_LoadFileText_SaveFileText.c
57 lines (42 loc) · 1.96 KB
/
Beginners_-_LoadFileText_SaveFileText.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "raylib.h"
#include "string.h"
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib example.");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// We create a char with some text in it. It must end with '\0'
char savethis[100]="is this allright?\0";
// Save this string as test.txt to the current folder.
SaveFileText("test.txt",savethis);
// Create a char to let our pointer use.
static char myloadstring[128];
// Create a pointer to our char.
static char *loadthis = myloadstring;
// Load the text we saved previously into the loadthis.
loadthis = LoadFileText("test.txt");
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw the text from pointer char 'loadthis' to the screen.
DrawText(loadthis,50,50,20,BLACK);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}