37 lines
624 B
C
37 lines
624 B
C
|
|
#include <stdio.h>
|
||
|
|
#include <stdlib.h>
|
||
|
|
#include <string.h>
|
||
|
|
|
||
|
|
#define MAX_NAME 64
|
||
|
|
#define GREETING "Hello, World!"
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
int id;
|
||
|
|
char name[MAX_NAME];
|
||
|
|
double score;
|
||
|
|
} Player;
|
||
|
|
|
||
|
|
int add(int a, int b) {
|
||
|
|
return a + b;
|
||
|
|
}
|
||
|
|
|
||
|
|
void greet(const char *name) {
|
||
|
|
printf("%s, %s!\n", GREETING, name);
|
||
|
|
}
|
||
|
|
|
||
|
|
int main(void) {
|
||
|
|
Player p = {1, "Alice", 95.5};
|
||
|
|
greet(p.name);
|
||
|
|
|
||
|
|
int result = add(3, 4);
|
||
|
|
printf("3 + 4 = %d\n", result);
|
||
|
|
|
||
|
|
FILE *fp = fopen("test.txt", "w");
|
||
|
|
if (fp) {
|
||
|
|
fprintf(fp, "id=%d,name=%s,score=%.1f\n", p.id, p.name, p.score);
|
||
|
|
fclose(fp);
|
||
|
|
}
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|