[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/hdglc/ - How did /g/ Learn C
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 98
Thread images: 9
File: index.png (5 KB, 225x225) Image search: [Google]
index.png
5 KB, 225x225
How did /g/ learn C?
Feel free to provide detailed stories and resources.
>>
>>54264192
cplusplus forums
>>
The k&r book. Right now going though the Linux programming interface book. It's very informative and lots of good c code in it.
>>
>>54264203
es la verdad familia
>>
>>54264192
I'm reading "Pointers on C". it's excellent and way more advanced than K&R (I skimmed it and read the first few chapters once) but long-winded as fuck
>>
>>54264278
why did you repost?
>>
>>54264192

Coming from a Pascal background...

C Programming - Made Simple [Sexton]
Algorithms in C - Sedgewick.
>>
>>54264298
swallowed a word before
>>
I read some very, very basic and old book by Alan Neubauer about C and C++.
Then I got some really bad book about Borland C of some polish author.
Wrote some C++ crap code based on what I read from some computer mag.
Went to Uni, there used all the scraps of knowledge together that I learned before, learned from lectures, started reading the K&R book and did a shit ton of basic programming exercises. Then I used C for algorithms and other classes. It became my main language for doing thing. I implemented a list data structure many times over and over, stacks, queues etc.
>>
Why are you asking, OP? Do you want to learn ANSI C?
>>
>>54264192
I opened a .c file and started learning. Then I readed The C ANSI Programming Language.
>>
>>54264352
> Why are you asking, OP? Do you want to learn ANSI C?
Well, yes, I am looking for the best way to learn because I am reading a book called "Beiginner's Guide to C" and it is kind of informative but doesn't TEACH me anything except syntax and has a blackjack program at the end. I read some of K&R and got kind of freaked out because it wasn't for beginners. I mean I am going to finish the first book I noted. The main reason I am learning is because I want to be able to contribute to the kernel dev and I need to also know how the os works with the C code and blah and want to know how to actuall implement all of it into one work such as: knowing C, how to read C, how to use C.
>>
>>54264501
K&R is the best book in my opinion. Then read some simple programs source code and modify it. Start programming as soon as possible eg. after reading the first chapter of K&R. I like your motivation, good luck.
>>
>>54264535
:) Thank you so much, most of /g/ tells me to go back to /b/.
So should I drop this book I am reading and go straight to K&R???
>>
I did some python at uni and tried a bit of c++ by myself I like it but decided to learn c instead
My main tip is stop worrying about which book and just fucking do it, I wasted so much time on looking up which book to use
>>
>>54264636
What book did you use ;-;
>>
>>54264636
>I wasted so much time on looking up which book to use
my life story
>want to learn something
>spend weeks on trying to find the right book, reading prefaces, tables of contents and reviews
>usually lose interest before picking up a book
>>
>>54264192
A Book on C. It really broke the language down in ways that were easy to understand. It does not provide much help for actually _using_ C to solve problems, though.
>>
>>54264675
Oh sorry I'm using k&r right now, maybe I find it a bit easier than you because I've already done a bit of python
>>
C is worthless. It's not the 80s anymore.
There is no excuse for manual memory management.
Anything you write is going to be inherently bug-ridden and dangerous.
>>
self-taught with K&R and web as a sophomore in HS and then I had a 1st semester class at Purdue.
>>
>>54264703
I did Python a while ago, never understood file systems though mainly because I used to use windows OS
>>
>>54264783
K&R?
>>
>>54264192
You people are so fucking retarded, stop fucking making generals for everything.

If you have nothing original to discuss, don't fucking repeat the same shit over and over. Stop.
>>
>>54264719
>no excuse for manual memory management
Enjoy your bloated software.
>>
I enrolled in my schools "intermediate programming" course, showed up to two classes, and did all my labs online while looking at references.

I got an A
>>
>>54264804
C Programming book.
>>
I had previously taken a C++ class but I didn't like it.

I downloaded K&R and spent several weeks doing the example problems on codeeval.
Now I'm a 3 star programer.
>>
>>54264844
What about C++ reference counted smart pointers?
>>
>/hdglc/
Is this really necessary?
>>
>>54264686
b-but anon, you can read them all and then write the reviews yourself in the time you spend reading reviews
>>
>>54264192
You've got to practice to learn C.

Using C, write a program that will tell you if a number is odd or even.
>>
>>54266754
>Using C, write a program that will tell you if a number is odd or even.

#include <stdio.h>

void main() {
char c = getchar():
if(c=='1' || c=='3' || c=='5' || c=='7' || c=='9' || c=='11' || c=='13' || c=='15' || c=='17' || c=='19' || c=='21' || c=='23 || c=='25' || c=='27' || c=='29' || c=='31' || c=='33' || c=='35' || c=='37' || c=='39' || c=='41' || c=='43' || c=='45' || c=='47' || c=='49' || c=='51' || c=='53' || c=='55' || 'c=='57 || c=='59' || c==6'1' || c=='63' || c=='65' || c=='67' || c=='69' || c=='71' || c=='73' || c=='75' || c=='77' || c=='79' || c=='81' || c=='83' || c=='85' || c=='87' || c==89 || c=='91' || c=='93' || c=='95' || c==99) {
printf("Number is odd" ;
} else {
printf("Number is even" ;
}
}

How did I do?
>>
>>54266916
kek10/10
>>
>>54266916
Great job anon, you truly grasp if-else control flow.
>>
>>54264192
Was already fluent on Pascal, Ada and Basic.

Job required C Code, so I started learning C.

First code was parsing UML "by hand" to get a grasp on the language. Then some feature extractor built upon a newer version of said code that used a prebuilt parser. Soon, all my private projects were C. Shortly after I expanded my focus to C++.
>>
>>54267085
>Was already fluent on Pascal, Ada and Basic.
how old are you?
>>
>>54267099
30, but I started early.
>>
>>54267135
Turbo Pascal 4.0 was my first language. Compiler and IDE from some hand-me-down book. Times were good.
>>
>>54267162
*standard, not language.
>>
Made games with c++ and sdl for a good number of years. C wasnt much different (i liked it more though for game dev)
>>
>>54264192
Books, and now I'm taking a course that requires it. I hate it. It's taking me longer to finish these assignments than any other assignments I have ever had in any other language.
>>
File: u3.png (10 KB, 640x399) Image search: [Google]
u3.png
10 KB, 640x399
When I was a kid I was completely enthralled by computers and obsessed with figuring out what I could do with them and taking apart games and programs to see what made them tick and eventually learning to program myself. Starting from fucking around with PEEK and POKE on a C64 and playing around with a fairly more powerful version of basic on the Atari ST my father brought home a photocopied C manual (don't even remember which one) and I started learning from there. Later on I found a book at the library that had mathematical equations for transforming 2d coordinates into 3d space and managed to write code using them to render simple wireframe cubes and shit. It was really amazing seeing that actually work.

My favorite thing I did back when I was a kid though was around the era when Ultima III, IV were out on Atari/Amiga, and I thought "I can do this better" so I wrote a basic engine that used tile graphics like Ultima but dynamically cycled the palettes from normal to reds and blues to simulate a day/sunset/night cycle, and figured out a way to draw player sprites transparently over a tile so the black areas didn't obscure the tile beneath, using xor bitblitting or some shit, I don't remember. Oh yeah and random pixels to simulate weather effects too. Shit was so cash. Too bad I was too young to know how to turn it into an actual product.

My advice to you if you really want to get into programming is to just really love programming. Always be playing around with something, whenever you have an idea for some data structure or process to compute some information, just jump right in and try it out, even if you're not working on games it's fun and rewarding to come up with a little piece of code that handles a task beautifully.
>>
>>54264192
a professor in uni who i knew wanted me to work for him.

>hey anon, you want to work for me writing testbenches for my assembly optimizer team?
ss-sure, what do i need to know? (studying physics at the time, no programming other than a bit mathematica shit)
>oh nothing much, just write a testing framework for our stuff in c
bb-b-ut i don't know any c
>not a problem, here's a k&r, you'll get through it in a night

--- a stressful 2 weeks later ---

oo-okay, i think i can do this now
>great you start tomorrow. first we need a function that parses an XML file into c structs and then we need to iterate over those for every member in a list of function pointers. the programs we wrote which need to be tested are already waiting, would be great if we could start testing tomorrow. bye, going home now
shitshitshitshitshitshitshit

this happened a few times over the following couple weeks, at the end of it i knew c really well, changed courses to computer science (had been thinking about a switch for a while but didn't really know what to) and blasted through that. then went on to work parallelizing c code for the high performance computing department which fucked my mind up good again, while simultaneously tutoring c programming projects and grading project groups on their code, reviewing a lot of bad c code.

that's my story.
>>
3 years in c++ made learning c a breeze, but as a guide, I worked through Beej's Guide to Network Programming and Advanced Programming in the UNIX Environmnt 3E.
>>
Stephen Kochan - Programming in C

plus

Head First C

worked pretty well for me to learn

also read the first half or so of K&R
>>
I'm sorry to interrupt everybody here, i'm trying to get into programming and i see alot of people recommend "K&R". when googling "K&R programming C " i get a book from Dennis Ritchie and Brian Kernighan.

Is this the correct one ?

thanks
>>
>>54268022
Yeah, you want the second edition
>>
>>54268073
thanks anon.
have a great night.
>>
>>54264192
Slept through my C class at uni, so just barely learned the syntax. From there I got an internship in embedded systems and had to learn fucking fast or get fired. Poking around in the Linux kernel is really helpful.
>>
>>54264192
By playing around with SDL.
>>
>>54266916
noteventrying/10
>>
>>54264192
By programming in it.
>>
>>54264192
University required its use
>>
>>54267658
I really, really like this post.
>>
>>54266916
Absolute genius... no expand this to cope with 1 ... 1000. Shit post the result.
>>
>>54264192
Practical C by O'Reilly. I read K&R later when I understood the language better.
>>
Started by reading this http://blacklight.gotdns.org/guidac.pdf

I didn't mind reading stuff in english at that time, but that book is very good. I had very few basics in python and nothing else back then, yet it was fairly easy to learn from it. Keep in mind that I'm talking about learing basic stuff, I'm still learning C/C++ after 7+ years.
>>
File: 1461847291820.png (33 KB, 400x400) Image search: [Google]
1461847291820.png
33 KB, 400x400
Everybody is so nice and polite in this thread
>>
What about learn C the hard way?

I know the dude who wrote it got savaged for saying KR was shit and outdated but is the book itself ok for learning modern C?
>>
>>54271602
If it's your first programming language, then it's more about the variary of example problems you solve, than about the age of your books. Books can give basic ideas but you can only truly learn to programm by practice.
>>
>>54270741
http://pastebin.com/HBER75nU
>>
>>54271456
Fuck off faggot. Go use a meme language.
>>
File: cover.jpg (678 KB, 1075x1326) Image search: [Google]
cover.jpg
678 KB, 1075x1326
Pic related is excellent.
>>
>personal projects

What advice would you give to a guy who is familiar with the basics of C and C++ but has no idea what to do with it? (I only know how to make console applications, as an EE my classes only covered this and never touched upon GUI stuff)

I mean I'm capable of performing set tasks but I have no creative thought with which to practice/polish my code or to produce something that is actually of use to either others or myself.
>>
>>54266916
This is so wrong. You should use switch case instead and compile with -O3.
>>
By reading the Borland Turbo C documentation. Also when I switched to Linux I downloaded the source code of various programs and read them. That's the best way to learn any language, read the source code of other people.
>>
Unrelated question, should i pick up the habit of commenting in my code ?
Don't get me wrong, formatting is fine,elegant even, but I always forget to comment stuff. It seems like a time waste.
>>
>>54271759
>http://pastebin.com/HBER75nU
Thanks Pajeet. Cheered me and the guys up no end.
>>
>>54272990
>1 liner above the function, giving a brief explanation of what it does
>>
File: JUST END ME FAM.jpg (302 KB, 1280x720) Image search: [Google]
JUST END ME FAM.jpg
302 KB, 1280x720
>>54264192
>/hdglc/
>/dpt/
>/csg/
>/sqt/
>/edc/
>/hpg/
>/spg/
>/wtg/
>/wdg/
>>
>>54264867
Worst form of gc.
>>
>>54264535
is it still worth reading K&R? I've heard it's pretty out of date, but ive still been thinking about it
>>
Uni
first semester cs
We had java and c
Java prof: java is the best because its easy to use
C prof: don't listen to java prof, its shit for people that aren't doing anything serious, c is still used everywhere relevant

After that we kept on using java

I liked c more desu
>>
>>54273393
Yes absolutely, it's an amazing piece of teaching. Follow it with 21st Century C if you're worried about being outdated.
>>
File: 0673999866.jpg (162 KB, 500x648) Image search: [Google]
0673999866.jpg
162 KB, 500x648
What do you think about this book?
>>
I learned C by reading simple examples and experimentation. Stackoverflow also helped quite a lot. Aside from a little bit of experience with gamemaker scripting C was my first programming language.
>>
>>54272990
try to write code that is elegant enough that you don't need to comment it much. but make SURE to document (at least with a quick 1 line) every function in your .h files, especially if you intend other people to use your code
>>
>>54271602
zed shaw is a hack and learn C the hard way is terribly written

it's teaching method is basically
>copy this program verbatim and then try to break it and tell me why it broke
it works alright for simple functions but the examples get stupidly long (500 lines) and the author goes full retard by chapter 20, using structs according to design patterns that would seem alien to the beginner.
>>
>>54264192
engineering class

though I don't know it very in depth
>>
Learned some in high school for exam. Then refined with k&r
>>
File: kertakayttoon_shibakoira.jpg (111 KB, 1230x820) Image search: [Google]
kertakayttoon_shibakoira.jpg
111 KB, 1230x820
>>54271759
God damn
>>
I never bothered because I have a real job.
>>
>>54264192
http://www.cs.cf.ac.uk/Dave/C/
this website is the shit
>>
mostly via reading datasheets and the specs of the language.

It is really intuitive and should be taught to all beginners even if they eventually move on to something more suited for their needs.
>>
>>54264719
>There is no excuse for manual memory management.
Is this b8? Manual memory management is a must for performance critical applications.
>>
File: ShowCover.jpg (67 KB, 500x621) Image search: [Google]
ShowCover.jpg
67 KB, 500x621
Read this book in '99.
>>
>>54264192
I coded a few modules for something and got coached by the main dev. Though I already knew other programming languages, so the only thing I really needed was understanding malloc, undefined behavior and string manipulation
>>
>>54264192
>How did /g/ learn C?
In university like a normal person
>>
Started with C#, got into reverse engineering and that led to C
>>
File: turboc.gif (68 KB, 450x283) Image search: [Google]
turboc.gif
68 KB, 450x283
High school tech classes. About a year was dedicated to C, half of it alongside Assembly. Noting down lectures (no textbook), solving exercises on pen and paper, occasionally firing up Turbo C in the computer lab. We did not receive a copy of the compiler to install at home, and I was afraid of wrecking the computer anyway.
Still, I learned C just fine. Transitioned smoothly to MATLAB in college, and still occasionally review moldy embedded C code at work to imbibe arcane knowledge.
>>
>>54277253
1990's or India?
>>
enjoy your memoryleaks
>>
>>54277304
Code monkey detected.
>>
I learned c, from friends, instructors and eventually the inte internet and youtube/stackoverflow.
>>
>>54277299
Wrong on both counts. Israel, class of 2007. It was a prestigious school in a big city belonging to a major university, but at the same time it was a run-down and underfunded institution on the verge of closing down.
Awesome education overall, though. C was one of six technical subjects I got to learn, not including electives.
>>
What's the best way to learn C for someone who already knows Java?
>>
>>54277887
maybe K&R from what I am hearing.
Thread replies: 98
Thread images: 9

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.