What's new?
|
Help
|
Directory
|
Sign in
heron-language
Heron is an object-oriented programming language for model driven architecture
Project Home
Downloads
Wiki
Issues
Source
Checkout
|
Browse
|
Changes
|
Source Path:
svn
/
trunk
/
yard
/
yard_io.hpp
r47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Dedicated to the public domain by Christopher Diggins
#ifndef IO_HPP
#define IO_HPP
int FileSize(const char* filename)
{
int r = 0;
FILE* f = fopen(filename, "r");
while (!feof(f))
{
fgetc(f);
++r;
}
fclose(f);
return r;
}
char* ReadFile(const char* filename)
{
int n = FileSize(filename);
char* result = (char*)malloc(n + 1);
char* p = result;
FILE* f = fopen(filename, "r");
if (f == NULL)
return NULL;
char c = fgetc(f);
while (!feof(f))
{
*p++ = c;
c = fgetc(f);
}
*p = '\0';
fclose(f);
return result;
}
#endif
Show details
Hide details
Change log
r42
by cdiggins on Mar 24, 2008
Diff
Compiles and works. Renamed "misc/io.hpp" to "yard/yard_io.hpp"
Go to:
/trunk/heron.vcproj
/trunk/heron_main.cpp
/trunk/misc/io.hpp
/trunk/yard/yard_io.hpp
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 594 bytes, 38 lines
View raw file