Created
January 28, 2019 14:31
-
-
Save thrimbor/d2b1babe8b582e48304773cf5c2efcf7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <xboxkrnl/xboxkrnl.h> | |
#include <assert.h> | |
#include <string.h> | |
int main() { | |
FILE *fp; | |
fp = fopen("D:\\test.txt", "w"); | |
assert(fp != NULL); | |
fprintf(fp, "This is testing for fprintf...\n"); | |
fputs("This is testing for fputs...\n", fp); | |
fclose(fp); | |
fp = fopen("D:\\test.txt", "a"); | |
assert(fp != NULL); | |
fprintf(fp, "Testing appending (%d)\n", 123); | |
fclose(fp); | |
fp = fopen("D:\\test.txt", "rb"); | |
assert(fp != NULL); | |
char buf[256]; | |
size_t read; | |
read = fread(buf, 1, 255, fp); | |
buf[read] = '\0'; | |
fclose(fp); | |
assert(strcmp(buf, "This is testing for fprintf...\nThis is testing for fputs...\nTesting appending (123)\n") == 0); | |
DbgPrint("Read content: %s\n", buf); | |
fp = fopen("D:\\nonexistent.txt", "r"); | |
assert(fp == NULL); | |
fp = fopen("D:\\nonexistent.txt", "rb"); | |
assert(fp == NULL); | |
fp = fopen("D:\\test.txt", "r"); | |
assert(ftell(fp) == 0); | |
fseek(fp, 1, SEEK_SET); | |
assert(ftell(fp) == 1); | |
fseek(fp, 2, SEEK_CUR); | |
assert(ftell(fp) == 3); | |
fseek(fp, 0, SEEK_END); | |
assert(ftell(fp) == 84); | |
fclose(fp); | |
DbgPrint("Everything's fine\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment