Skip to content

Instantly share code, notes, and snippets.

@junhoyeo
Created November 12, 2019 12:51
Show Gist options
  • Select an option

  • Save junhoyeo/15b601031b14c54165465a4e455a64b4 to your computer and use it in GitHub Desktop.

Select an option

Save junhoyeo/15b601031b14c54165465a4e455a64b4 to your computer and use it in GitHub Desktop.
오영준구원해드림 적용알아서
#pragma once
#ifndef _SAVE_SCORE_
#define _SAVE_SCORE_
#include <stdio.h>
// score.txt에서 현재 점수를 가져온다.
int load_score() {
int score;
FILE * fp = fopen("./score.txt", "r");
fscanf(fp, "%d", &score);
fclose(fp);
return score;
}
// 인수로 받은 int형의 score를 score.txt에 저장한다.
void save_score(int score) {
FILE *fp = fopen("./score.txt", "w");
fprintf(fp, "%d\n", score);
fclose(fp);
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment