This situation is why there is "hello world"; that program seems trivial but actually has important implications; for instance, that your environment works, that you know how to feed programs to the compiler, that you can actually run the output. I never took "hello world" seriously until I started doing embedded systems work; it's now an extraordinarily important tool for me (I work an anomalously weird number of di…
I once had a particularly slow week at work, and decided to write an article about how "Hello World" works in C. How it really works -- including compiling, linking, system calls, operating system involvement, hardware I/O, communication between ICs, etc. The path from the block of text to photons emitting from the screen, with fairly detailed explanations at every level. I ended up with a 50 page LaTeX document that…
Where to begin when learning C? Start by making lots of errors
31–40 of 90 posts
Re: Where to begin when learning C? Start by making lots of errors
#32Earlier quoted context omitted.
I once had a particularly slow week at work, and decided to write an article about how "Hello World" works in C. How it really works -- including compiling, linking, system calls, operating system involvement, hardware I/O, communication between ICs, etc. The path from the block of text to photons emitting from the screen, with fairly detailed explanations at every level. I ended up with a 50 page LaTeX document that…
I second the motion to post the unfinished guide! Perhaps on Github where some other HN guys can make it complete for you. Regardless, I think it's a great idea, and would really give insight as to why things work the way they do, instead of us just seeing Hello World!
Re: Where to begin when learning C? Start by making lots of errors
#33I learned C by reading K and R and doing the book's exercises . . . on paper. At the time I didn't have access to a C compiler, so I wrote them all out in a notebook. A month later I got a job at a shop that was running Unix, and got the chance to type my programs in and try them. I had a lot of things wrong. It took me a while to understand the difference between control-D and EOF, for instance (how embarrassing). B…
(The companion book "Programming in the UNIX environment" is the get-you-started guide from the very beginning, although it assumes 1970s terminal defaults)
Re: Where to begin when learning C? Start by making lots of errors
#34Actually the message quoted complains about the lack of _main not main, so the rest of this post is a huge overinterpretation. _main is IMO some windoizm connected to the use of WinMain for GUI apps.
Re: Where to begin when learning C? Start by making lots of errors
#35Actually the message quoted complains about the lack of _main not main, so the rest of this post is a huge overinterpretation. _main is IMO some windoizm connected to the use of WinMain for GUI apps.
http://stackoverflow.com/questions/2627511/why-do-c-compiler...
Re: Where to begin when learning C? Start by making lots of errors
#36By the way, I would love any feedback on this approach and where I should take this further.
http://c.learncodethehardway.org/book/Re: Where to begin when learning C? Start by making lots of errors
#37Re: Where to begin when learning C? Start by making lots of errors
#38Earlier quoted context omitted.
And probably -Werror (all warnings become errors, breaking compilation). Fun post. Now I know why everyone was raving about the clang error-messages: echo "void main() {}" > main.c gcc -Wall -Werror --std=c99 main.c main.c:1:6: error: return type of ‘main’ is not ‘int’ [-Werror=main] cc1: all warnings being treated as errors clang -Wall -Werror --std=c99 main.c main.c:1:1: error: 'main' must return 'int' void main()…
Nice suggestion. Although I can't seem where one would have to look for those "pretty colours" you mentioned, I certainly can't see any of them on my Mac terminal...
http://i.imgur.com/BjWj7h6.png
FWIW, I have:
COLORTERM=gnome-terminal
TERM=screen
and Debian takes care of my termcap etc, afaik.Re: Where to begin when learning C? Start by making lots of errors
#39Actually the message quoted complains about the lack of _main not main, so the rest of this post is a huge overinterpretation. _main is IMO some windoizm connected to the use of WinMain for GUI apps.
Are you trying to dispute the fact that `main()` is THE entry point for any C program? I'd be interested in hearing a more comprehensive explanation.
Re: Where to begin when learning C? Start by making lots of errors
#40Actually the message quoted complains about the lack of _main not main, so the rest of this post is a huge overinterpretation. _main is IMO some windoizm connected to the use of WinMain for GUI apps.
-1, Learn don't guess. http://stackoverflow.com/questions/2627511/why-do-c-compiler...