I'm planning on learning some C as an introductory language, having done just a bit of basic and html in my youth, and having knowledge of algorithms from mathematics.
Does anyone have any pointers to some good books or sites for C (books preferred)?
By "good" I mean neophyte-friendly and easy to read.
Name:
Anonymous2005-06-10 3:18
You'll have lots of "pointers" :)
C is a pretty neat language, and it's what you end up using whenever you want to do anything really serious, especially system-related. Good choice.
I'd Google for C tuturials; you can choose five or so, then start in random order, do it for the first 10 minutes, and move on to the next one if you don't like what you see. It's usually the best way, I think.
Name:
Anonymous2005-06-10 3:29
you would be well advised to learn something more high-level first
Name:
Anonymous2005-06-10 6:33
You already know some Basic, right?
If you still don't feel comfortable with low-level stuff such as pointers, try Pascal, you'll like it (it's like Basic but more sorted of, with a more regular syntax that sucks less, and still strongly typed and all). Don't listen to the Java trend, never start with an OO language, much less Java, or you'll go crazy.
Name:
Edward2005-06-10 9:38
Well the deal is I'm a philosophy and physics student who is more of a specialist in philosophy of mind, cognition& epistemology, and Logic & semantic analysis. One of my friends thinks I'd do pretty well in a her Nat. Lang. Processing group. Although this isn't exactly my field it's a nice option to keep open.
Anyway, thing is I need a bit more mastery of the whole programming logic mindset. She told me to take a good look at C over the summer, as that would develop the sturdy reflexes I might need. So yeah, I'm staying well away from the complexity of OO stuff.
I've found an O'Reilley book. Might buy it, they're pretty good writers.
Name:
Christy McJesus!DcbLlAZi7U2005-06-10 10:35
I malrecommend C as a first language, unless you actually want to get down to the system level. If you want to do high level programming, learn a high level programming language. Also Pascal can bite me - oh wait, no it can't even do that.
Name:
Anonymous2005-06-10 19:55
>>6
Pascal is bitchy and you can't do much with it, but I think it's good to learn programming because it's strongly structured and typed, and I think it'll adapt best to Edward's profile.
it's true what >>6 says (gasp). with your background I'd recommend any of the following: scheme, haskell, ml, ocaml, c-lisp or python, and in that order too.
If you're set on C then pretty much any book will do (ultimately, all intro-level books say the same things), but it's not going to be an easy or rewarding experience.
The C Programming Language
by Brian W. Kernighan and Dennis M. Ritchie
is THE C book.
Name:
Anonymous2005-06-12 18:48
'The C Programming Language'
Rather expensive to find a copy of and isn't mean't to teach you the language. Serves primarily as a reference.
Name:
Anonymous2005-06-12 20:35
I went and learnt C with it. I don't know if it's the best way to learn though. It probably is, but only if you already know other languages.
Name:
Anonymous2005-06-13 7:47
>>11
I agree with >>12, I learned C by writing my own stuff and the best book I've read is a french book called "The C language" by Claude Delannoy, IMHO it's better than the K&R and goes deeper in what the language can do.
Name:
abez!XWEgiX8ArQ2005-06-20 21:57
I'm not going to recommend a book, I'm going to recommend you find a peice of open source software you enjoy using that is relatively simple and I recommend you read that software. In the software industry we don't get to read other people's code alot, writers learn from each other by reading each other's work. Until recently this has not been possible for programmers, but now you can, so I suggest you take advantage of open source software by reading some of the code out there.
Name:
Anonymous2005-06-22 0:50
I'm running NetBSD; I have the entire 2.0 source tree; but I can't make heads or tails out of anything I'm reading.
Is there anything online that I can read that fills the gap between using basic C statements and reading production-quality code?
Name:
Christy McJesus!DcbLlAZi7U2005-06-22 4:14
Apparently the OpenSolaris team are giving online guided tours of their source code. I might have a look at that, because I have difficulty reading other people's C code too, C not being my first language.
Name:
Anonymous2005-06-22 13:50
>>17 are you talking about their source code browser? Because I'm pretty sure there's one for linux and also one for some sort of bsd too.
Also, if you snoop around tuhs.org you'll find a page that lets you browse ancient unix (7th ed?) source code too.
Yah, I dig that. But the difficulty and especially the rigor needed to understand and work with C based languages is supposed to be a great foundation for the the sort of thinking you have to do in computer science. I personally would rather stick to my perl book, but apparently I'd develop too many bad knacks, given perl is pretty lax.
>>everyone Cheers for the links, or the 'pointers'. Hehe.
I guess I am. I just remember seeing an article about "guided tours", but when I got to their site all there was was a source code browser. Hell I'd rather just download it and use vim.
Name:
Anonymous2005-06-26 22:37
Okay technical question. I I have:
char a[5][5];
char b[5][5];
How do I swap these two arrays so that `a` points to the data in `b` and vice versa?
Name:
Anonymous2005-06-26 22:37
Okay technical question. If I have:
char a[5][5];
char b[5][5];
How do I swap these two arrays so that `a` points to the data in `b` and vice versa?
Name:
Anonymous2005-06-26 23:24
>>21 I'm sure I"m wrong; but i would come up with a third array (c) and swap the contents of b into it using a for loop, then swap the contents of a into b in a second loop, then finally use a third loop to swap the contents of c into a.
Again, I'm a noob and I'm sure there's a much more efficent way of doing this; but that's how *I* would do it (knowing what I know now).
Name:
Anonymous2005-06-27 2:13
Too much work. They're just pointers:
char *p = a;
a = b;
b = p;
Name:
Anonymous2005-06-27 20:52
>>24
foo.c:7: warning: initialization from incompatible pointer type
foo.c:8: error: incompatible types in assignment
foo.c:9: error: incompatible types in assignment
>>32
foo.c:5: warning: cast from pointer to integer of different size
foo.c:5: error: invalid operands to binary ^
foo.c:6: warning: cast from pointer to integer of different size
foo.c:6: error: invalid operands to binary ^
foo.c:7: warning: cast from pointer to integer of different size
foo.c:7: error: invalid operands to binary ^
Name:
Anonymous2009-01-16 3:33
t = malloc(sizeof(a))
if(!t) for(;;fork()) puts("GET MORE MEMORY, YOU IDIOT!");
memcpy(t, a, sizeof(a));
memcpy(a, b, sizeof(a));
memcpy(b, t, sizeof(a));
free(t);
Name:
Anonymous2009-01-16 4:24
im writing my own language. currently it supports defining variables.
Name:
Anonymous2009-01-16 4:26
Edward, please listen to me.
READ SICP.
You will learn Scheme instead of C but as long as you have read SICP then learning C afterwards will be easy.
Name:
Anonymous2009-01-16 4:27
bmup
Name:
Anonymous2009-01-16 6:32
if(!t) for(;;fork()) puts("GET MORE MEMORY, YOU IDIOT!");
Oh god I lol'd. This is going into my production code.
#include <stdio.h> // include standard output/input functions
int main(void){ // main is a special function where the program always starts
printf("This is the output function.");
return 0;
}
Name:
Anonymous2009-01-16 10:41
<?xml version="1.0" encoding="utf-8"?>
<instruction xmlns="urn:GRUNNUR" xmlns:shiichan="http://dis.4chan.org/">
<action type="hax">
<shiichan:thread id="1118385778">
<shiichan:post id="45">
<anus />
</shiichan:post>
</shiichan:thread>
</action>
<reason><![CDATA[
Before you canhax anii, you must first learnBBCODE
]]>
</reason>
</instruction>
Name:
Anonymous2009-01-16 10:55
"hax" < main
{
main ->
stef(;)
stofn
hax(;1118385778,46),
stofnlok
C is fucking overrated. Just learn Haskell instead.
Name:
Anonymous2009-01-17 10:55
>>52
from the motherfucking haskell website, http://www.haskell.org/haskellwiki/Lazy_evaluation:
>Non-strict semantics allows to bypass undefined values (e.g. results of infinite loops) and this way it also allows to process formally infinite data.
>allows to bypass
>allows to bypass
obviously, haskell is for intelligent people :) lol
I'm not sure if it's an actual error, but I would regard it as bad style, since 'allow' should take a direct object. In addition, the verb form 'allows' and later pronoun 'it' disagree with the plurality of 'non-strict semantics'. I prefer “Having non-strict semantics allows bypassing undefined values …” or “Non-strict semantics allow bypassing undefined values …”.
>>67
Since i opened my blog ,i don't particularly care about my Slashdot comments: Blogs are superior form of communicating your opinion/info then posting on a moderated forum.Plus you can't comment old slashdot stories.
_________________________
orbis terrarum delenda est