Learn C

No programming experience, want to learn C. Where?

Other urls found in this thread:

publications.gbdirect.co.uk/c_book/
faculty.euc.ac.cy/scharalambous/csc131/books/C book 1.pdf
faculty.euc.ac.cy/scharalambous/csc131/books/C book 2.pdf
twitter.com/SFWRedditImages

lurking more

I still recommend people start with K&R.

Oh, no programming experience at all, hmm... I would say SICP if you're serious about computer science, if not, then find some online python tutorial.

sounds great, do you have an ebook?

thanks, looks interesting. i definitely need a CS background because C is too lowlevel, right?

Freely available online.


Too low level for what? You told us you wanted to learn C, but it seems you're not even sure why you should. Start with something like python or do SICP with Racket (a newer dialect of scheme).

SICP is online that is, K&R you can find in the books thread from the catalogue.

too low level to understand without having a more than very superficial CS understanding. i have some very minor experience with a scripting language similar to C from years ago, and C has this reputation, so i thought it'd be a good place to start learning. is python a better place to start? i thought it'd be better to check out python if i'm already dabbling in another language with more "boring" bits? thanks for the great suggestions and sorry, my understanding of programming comes exclusively from modding tools and webcomics.

I think Python would be a good fit. It's a language that doesn't really get in your way and you can just focus on the concepts. You certainly should learn C at some point, but you'll know when the time is right for that.

I cannot recommend any Python books, but I think they have a decent tutorial on their homepage. Try working through that.

i found everything. thank you everyone, my questions were answered perfectly.

Don't listen to these faggots. I learned C in middle school. The difficulty of C is way overblown.

Writing C isn't difficult. The problem is most people write shit C

Most people write shit everything.

The C Book by Addison Wesley
publications.gbdirect.co.uk/c_book/

C Primer Plus (5th ed)
faculty.euc.ac.cy/scharalambous/csc131/books/C book 1.pdf

K&R
faculty.euc.ac.cy/scharalambous/csc131/books/C book 2.pdf

Friendly reminder to read the standard after you have "learned" C.

How do you get started hacking on low level linux stuff in C or C++?

man 2 something

And witness undefined behaviour

I found this piece of code which I wish to fit in my program. Is it possible to XOR multiple bytes at once using std::vector as a buffer?

void decode(const unsigned char* in, unsigned char* out, size_t size){ size_t processleft = size; // let compiler optimize this const unsigned char *pin = in; unsigned char *pout = out; while ( processleft >= 4 ) { *reinterpret_cast(pout) = *reinterpret_cast(pin) ^ xor_key_4; pout += 4; pin += 4; processleft -= 4; } for ( size_t i = 0; i < processleft; ++i ) { *pout++ = *pin++ ^ xor_key_1; }}

forgot to include thisconst unsigned int xor_key_4 = 0x00282828;

Just read 4 bytes at a time into an unsigned integer and do the operation on that.

Tldp has some documentation on writing kernel modules.

by writing it. no need to read the whole K&R, but it's a good reference book.

Why does anyone bother with C++ casts. They're disgusting noise and contribute almost nothing.

Why not 8 with long long unsigned? uint64t/u64 is better.

because C++ is pretending to be an OO language
and OO & low level do not mix well together, hence lots of nonsense to make it somewhat usable

Also, start with SICP, this is ~the~ introductory book to all programming.

And what, address the upper and lower 32 bit chunks with an additional pointer?
I think it's better just to work in the appropriate units. Considering the key is 4 bytes in length, the data should also be handled in blocks of that size.
Feel free to teach me something if you have another theory about this though.

But there's no reason not to use C casts. All the C++ casts give you is some assertion checking of mistakes that are very rare and hard not to notice. They clutter the code and make it harder to read.

thanks, this seems to work
void xor_buffer(std::vector& buf){ size_t usize = sizeof(unsigned int); size_t bs = buf.size(); int leftover = bs % usize; for (int i=0; i= usize) { unsigned int *block = (unsigned int*)&buf[i]; *block = *block ^ xor_key_4; //0x00282828 } else break; } for (int a=0; a

That's some pretty shit code, you're depending on a specific type size but using types that could be 16 bit or larger. Use stdint types for this kind of thing.

ah crap. didn't think about that.

Is brute force/trial be error the way to program>

Nicely done.

Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered. Here's that spam you ordered.

K&R assumes you know at least a little bit of programming.
A complete beginner should at least take some lessons about variables and control structures before jumping into K&R


C is more low level than everything but assembly, but that doesn't mean it's harder. SICP teaches you a more high-level language and it doesn't make it less challenging.


if you understand variables, ifs and loops you are ready for K&R.
if all you want is learn programming then the language won't really matter


non-portable code detected.
use fixed-length data types. ints aren't required to be 32 bits

Not only this, but C doesn't scale either. Constantly reinventing the wheel is a hallmark of most C 'coders' and is of little commercial value to do so, only a pedagogic one. Abstraction is crucial for large-scale development and maintenance. If you need low-level performance and control then use C++. If those needs are less important, choose Java.

If money's tight, only use C on small scale embedded designs, or if lots of time and money is available and job security through obfuscation is possible, then use it on bigger distributed embedded systems like automobiles.

Regardless, C is on it's way out and C++ is rapidly overtaking it on pretty much all fronts, and for good reason.

And Java is unlikely to ever go away in the corporate development world, again, for good reasons.

Yes it's the only way but you should call it test driven development.


Thanks I needed a good laugh