Skip to content

Commit aa4624c

Browse files
committed
2 parents ee6f1b0 + 7e511e5 commit aa4624c

File tree

4 files changed

+71
-15
lines changed

4 files changed

+71
-15
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Contribution Guidelines
2+
3+
Please feel encouraged to make a pull request (PR) to correct or clarify code.
4+
5+
Some rough guidelines for making a PR:
6+
7+
* Bug fixes and operating-system specific fixes are very welcome.
8+
* When making a PR please make sure both the PR and the code is commented clearly for other book readers.
9+
* Do not introduce code copy-pasted from elsewhere as there are licencing and copyright issues with this.
10+
* Please do not submit CMakeLists.txt or build scripts for the entire book or for individual chapters. There is a specific chapter dedicated to introducing build systems.
11+
* Please do not submit project or solution files for a particular IDE.
12+
* Code in examples is copy-pasted from the book. If the PR needs to modify these please add a comment to those lines indicating why the change was important.
13+
* Code style and language version changes are discouraged unless they fix a bug.
14+
* If you are happy to be added to a contributors list then please add your name, as you would like it to appear, as a bullet at the bottom of this file.

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Please feel free to use the [Issues](https://github.com/capnramses/pro_programmi
6464

6565
## Contributions and Pull Requests
6666

67-
Please feel encouraged to make a pull request to correct or clarify code.
67+
Please feel encouraged to make a pull request (PR) to correct or clarify code.
6868

6969
Some rough guidelines for making a PR:
7070

@@ -75,4 +75,8 @@ Some rough guidelines for making a PR:
7575
* Please do not submit project or solution files for a particular IDE.
7676
* Code in examples is copy-pasted from the book. If the PR needs to modify these please add a comment to those lines indicating why the change was important.
7777
* Code style and language version changes are discouraged unless they fix a bug.
78-
* In your PR please indicate if you are happy to be added to a contributors list, and if so the name and/or handle you would like to be credited as.
78+
* If you are happy to be added to a contributors list then please add your name, as you would like it to appear, as a bullet at the bottom of this file.
79+
80+
## Contributors
81+
82+
* [Anton Gerdelan](https://github.com/capnramses) - Initial code.

ch03_02_read_entire_file/main.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@ Repository: https://github.com/capnramses/pro_programming_tools_c_cpp
99
#include <string.h>
1010

1111
struct file_record_t {
12-
void* data;
12+
void* data;
1313
size_t sz;
1414
};
15-
15+
1616
struct file_record_t read_file( const char* filename ) {
17-
struct file_record_t record;
17+
struct file_record_t record;
1818
memset( &record, 0, sizeof( struct file_record_t ) );
19-
19+
2020
FILE* fp = fopen( filename, "rb" );
21-
if ( !fp ) { return record; }
21+
if ( !fp ) { return record; }
2222
fseek( fp, 0L, SEEK_END );
2323
record.sz = (size_t)ftell( fp );
2424
record.data = malloc( record.sz );
2525
rewind( fp );
2626
fread( record.data, record.sz, 1, fp );
2727
fclose( fp );
28-
28+
2929
return record;
3030
}
3131

3232
int main() {
33-
struct file_record_t record = read_file( "in.ppm" );
34-
if ( !record.data ) {
35-
fprintf( stderr, "ERROR: reading file `in.ppm`\n" );
36-
return 1;
37-
}
38-
printf( "put entire file `in.ppm` in memory. %u bytes. data %p\n", (unsigned int)record.sz, (void*)record.data );
39-
return 0;
33+
struct file_record_t record = read_file( "in.ppm" );
34+
if ( !record.data ) {
35+
fprintf( stderr, "ERROR: reading file `in.ppm`\n" );
36+
return 1;
37+
}
38+
printf( "put entire file `in.ppm` in memory. %u bytes. data %p\n", (unsigned int)record.sz, (void*)record.data );
39+
return 0;
4040
}

0 commit comments

Comments
 (0)