mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-16 03:34:53 +02:00
Merge pull request #1217 from joesavage/master
[c/en] add missing semicolons, fix spacing, change main() to main(void), modify additional resources section
This commit is contained in:
@@ -55,7 +55,7 @@ int add_two_ints(int x1, int x2); // function prototype
|
||||
|
||||
// Your program's entry point is a function called
|
||||
// main with an integer return type.
|
||||
int main() {
|
||||
int main(void) {
|
||||
// print output using printf, for "print formatted"
|
||||
// %d is an integer, \n is a newline
|
||||
printf("%d\n", 0); // => Prints 0
|
||||
@@ -183,8 +183,8 @@ int main() {
|
||||
i1 / i2; // => 0 (0.5, but truncated towards 0)
|
||||
|
||||
// You need to cast at least one integer to float to get a floating-point result
|
||||
(float)i1 / i2 // => 0.5f
|
||||
i1 / (double)i2 // => 0.5 // Same with double
|
||||
(float)i1 / i2; // => 0.5f
|
||||
i1 / (double)i2; // => 0.5 // Same with double
|
||||
f1 / f2; // => 0.5, plus or minus epsilon
|
||||
// Floating-point numbers and calculations are not exact
|
||||
|
||||
@@ -634,7 +634,7 @@ Best to find yourself a copy of [K&R, aka "The C Programming Language"](https://
|
||||
It is *the* book about C, written by Dennis Ritchie, the creator of C, and Brian Kernighan. Be careful, though - it's ancient and it contains some
|
||||
inaccuracies (well, ideas that are not considered good anymore) or now-changed practices.
|
||||
|
||||
Another good resource is [Learn C the hard way](http://c.learncodethehardway.org/book/).
|
||||
Another good resource is [Learn C The Hard Way](http://c.learncodethehardway.org/book/).
|
||||
|
||||
If you have a question, read the [compl.lang.c Frequently Asked Questions](http://c-faq.com).
|
||||
|
||||
|
Reference in New Issue
Block a user