File Input 1
Reading an Entire File
Read an entire file into memory, print the contents, and terminate the file.
This is the fifth part of the File Input Tutorial contributed by harleyg of PSP-Programming.com's forums (originally posted as generic C code here). Parts one, two, three, and four need to have been completed before proceeding.
You'll need your standard Makefile (place it in a new textfile called "Makefile" with no extention):
OBJS = main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = File Input Tutorial 1
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Then just type "make" in CYGWIN and you're set.
Except for one thing. You need a text file. Open up Notepad and write something in a file, then save it as "myfile.txt" (without quotes) and put it on your PSP with your EBOOT.
Congratulations, you just read a file in C. You can now use this to read in settings for your program and have external data. This can be very useful for creating programs that need user configuration; you can change the configuration without recompiling the file!
More File I/O tutorials are coming soon, expect more advanced topics and techniques to follow.
Be sure to add the feed to your RSS Aggregator (or Google Homepage, or Firefox Live Bookmark) to stay updated with the latest tutorials.
If you have any questions about this or about PSP programming in general, stop by the forums.