-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
33 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef STDIO_H | ||
#define STDIO_H | ||
#include <stdlib.h> | ||
|
||
typedef struct _iobuf { | ||
char *_ptr; | ||
int _cnt; | ||
char *_base; | ||
int _flag; | ||
int _file; | ||
int _charbuf; | ||
int _bufsiz; | ||
char *_tmpfname; | ||
} FILE; | ||
|
||
FILE *fopen(const char *filename, const char *mode); | ||
int fclose(FILE *stream); | ||
size_t fwrite(const void *ptr, size_t size, size_t count, FILE *stream); | ||
size_t fread(void *ptr, size_t size, size_t count, FILE *stream); | ||
int printf(const char *format, ...); | ||
|
||
#endif // STDIO_H |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef STDLIB_H | ||
#define STDLIB_H | ||
|
||
typedef int size_t; | ||
|
||
#endif // STDLIB_H |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
#include <stdarg.h> | ||
#include <stdio.h> | ||
|
||
int sum(int num, ...) { | ||
int res = 0; | ||
va_list args; | ||
va_start(args, num); | ||
int i; | ||
for (i = 0; i < num; i++) { | ||
res += va_arg(args, int); | ||
} | ||
va_end(args); | ||
return res; | ||
int main() { | ||
FILE *f = fopen("test.txt", "w"); | ||
fwrite("Hello, World!\n", 1, 14, f); | ||
fclose(f); | ||
} | ||
|
||
int main() { return sum(10, 20, 30); } |