Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Diving into C

Name: Edward 2005-06-10 3:11

Hello people.

Quick question for you pedagogues out there...

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: Anonymous 2005-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: Anonymous 2005-06-10 3:29

you would be well advised to learn something more high-level first

Name: Anonymous 2005-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: Edward 2005-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 !DcbLlAZi7U 2005-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: Anonymous 2005-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.

Refer to this for more information:
http://www.indianz.com/board/topic.asp?TOPIC_ID=10016

Name: Anonymous 2005-06-11 3:14

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.

Name: Christy McJesus !DcbLlAZi7U 2005-06-11 10:19

>> scheme, haskell, ml, ocaml, c-lisp or python

Yeah pretty much.

Name: Anonymous 2005-06-11 11:54

>>1
>Programming in C
http://www.scit.wlv.ac.uk/cbook/

>LEARN C/C++ TODAY (A list of resources/tutorials)
http://www.faqs.org/faqs/C-faq/learn-c-cpp-today/

C++ tutorials: http://www.cprogramming.com/tutorial.html

Don't like any of those? http://www.google.com/search?q=c+tutorial

Name: Anonymous 2005-06-11 12:28

The C Programming Language
by Brian W. Kernighan and Dennis M. Ritchie
is THE C book.

Name: Anonymous 2005-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: Anonymous 2005-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: Anonymous 2005-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 !XWEgiX8ArQ 2005-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: Anonymous 2005-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 !DcbLlAZi7U 2005-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: Anonymous 2005-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.

Name: Edward 2005-06-22 18:39

>>6
>>7

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.

Name: Christy McJesus !DcbLlAZi7U 2005-06-23 9:48

>>18

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: Anonymous 2005-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: Anonymous 2005-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: Anonymous 2005-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: Anonymous 2005-06-27 2:13

Too much work. They're just pointers:

char *p = a;
a = b;
b = p;

Name: Anonymous 2005-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

Name: Anonymous 2005-06-27 21:18

>>25
I may be wrong but it may have to be

char **pp = a;
a = b;
b = pp;

Name: 24 2005-06-28 0:25

Sorry, I was mistaken. a and b are constants pointing to the stack, so >>23 was in fact correct.

For large arrays it might be easier and faster to allocate memory and swap the pointers instead.

Name: Anonymous 2007-09-02 14:55 ID:Heaven

lol

Name: Anonymous 2009-01-15 7:33

lol

Name: Anonymous 2009-01-15 8:14

>>5
Tell us more about this female. Have you had sex with her?

Name: Anonymous 2009-01-15 15:02

>>21-30
a^=b;
b^=a;
a^=b;

>>26 should work too

Name: Anonymous 2009-01-15 15:10

>>31
foo.c:7: error: incompatible types in assignment
foo.c:8: error: incompatible types in assignment
foo.c:9: error: incompatible types in assignment

Name: Anonymous 2009-01-15 15:14

>>31
foo.c:5: error: invalid operands to binary ^
foo.c:6: error: invalid operands to binary ^
foo.c:7: error: invalid operands to binary ^

Name: Anonymous 2009-01-15 19:12

>>32
a^=(char)b;
b^=(char)a;
a^=(char)b;

Name: Anonymous 2009-01-15 19:18

>>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: Anonymous 2009-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: Anonymous 2009-01-16 4:24

im writing my own language. currently it supports defining variables.

Name: Anonymous 2009-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: Anonymous 2009-01-16 4:27

bmup

Name: Anonymous 2009-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.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List