background preloader

Pointer Basics

Pointer Basics
This document introduces the basics of pointers as they work in several computer languages -- C, C++, Java, and Pascal. This document is the companion document for the Pointer Fun with Binky digital video, or it may be used by itself. This is document 106 in the Stanford CS Education Library. Section 1 -- Pointer Rules One of the nice things about pointers is that the rules which govern how they work are pretty simple. 1) Pointers and Pointees A pointer stores a reference to something. The above drawing shows a pointer named x pointing to a pointee which is storing the value 42. Allocating a pointer and allocating a pointee for it to point to are two separate steps. 2) Dereferencing The dereference operation starts at the pointer and follows its arrow over to access its pointee. The dereference operation on a pointer only works if the pointer has a pointee -- the pointee must be allocated and the pointer must be set to point to it. 3) Pointer Assignment Section 3 -- Study Questions

gotoAndLearn() - Free video tutorials from Lee Brimelow on Adobe Flash Mastering recursive programming For new computer science students, the concept of recursive programming is often difficult. Recursive thinking is difficult because it almost seems like circular reasoning. It's also not an intuitive process; when we give instructions to other people, we rarely direct them recursively. For those of you who are new to computer programming, here's a simple definition of recursion: Recursion occurs when a function calls itself directly or indirectly. A classic example of recursion The classic example of recursive programming involves computing factorials. An interesting property of a factorial is that the factorial of a number is equal to the starting number multiplied by the factorial of the number immediately below it. Listing 1. int factorial(int n) { return n * factorial(n - 1); } The problem with this function, however, is that it would run forever because there is no place where it stops. Listing 2. int factorial(int n) { if(n == 1) { return 1; } else { return n * factorial(n - 1); } }

Low Level Bit Hacks You Absolutely Must Know I decided to write an article about a thing that is second nature to embedded systems programmers - low level bit hacks. Bit hacks are ingenious little programming tricks that manipulate integers in a smart and efficient manner. Instead of performing some operation (such as counting the 1 bits in an integer) by looping over individual bits, these programming nuggets do the same with one or two carefully chosen bitwise operations. To get things going I'll assume that you know what the two's complement binary representation of an integer is and also that you know all the the bitwise operations. I'll use the following notation for bitwise operations in the article: & - bitwise and | - bitwise or ^ - bitwise xor ~ - bitwise not << - bitwise shift left >> - bitwise shift right The numbers in the article are 8 bit signed integers (though the operations work on arbitrary length signed integers) that are represented as two's complement and they are usually named 'x'. Here we go. Bit Hack #1. 1. 2.

Become a Programmer, Motherfucker If you don't know how to code, then you can learn even if you think you can't. Thousands of people have learned programming from these fine books: Learn Python The Hard Way Learn Ruby The Hard Way Learn Code The Hard Way I'm also working on a whole series of programming education books at learncodethehardway.org. Learn C The Hard Way Learn SQL The Hard Way Graphics Programming Language Agnostic NerdDinner Walkthrough Assembly Language Bash Clojure Clojure Programming ColdFusion CFML In 100 Minutes Delphi / Pascal Django Djangobook.com Erlang Learn You Some Erlang For Great Good Flex Getting started with Adobe Flex (PDF) Forth Git Grails Getting Start with Grails Haskell Java JavaScript JavaScript (Node.js specific) Latex The Not So Short Introduction to LATEX (perfect for beginners) Linux Advanced Linux Programming Lisp Lua Programming In Lua (for v5 but still largely relevant)Lua Programming Gems (not entirely free, but has a lot of free chapters and accompanying code) Maven Mercurial Nemerle Nemerle NoSQL Oberon Objective-C

Programming Methodology - Download free content from Stanford Signs that you're a bad programmer - Software Engineering Tips Why was this written? Most of these faults were discovered the hard way by the author himself, either because he committed them himself or saw them in the work of others. This paper is not meant for grading programmers, it was intended to be read by programmers who trust their ability to judge when something is a sign of bad practice, and when it's a consequence of special circumstances. This paper was written to force its author to think, and published because he thinks you lot would probably get a kick out of it, too. 1. Reasoning about code means being able to follow the execution path ("running the program in your head") while knowing what the goal of the code is. Symptoms Remedies To get over this deficiency a programmer can practice by using the IDE's own debugger as an aide, if it has the ability to step through the code one line at a time. 2. Object Oriented Programming is an example of a language model, as is Functional or Declarative programming. 3. 4. 5. 6. 1. 2. 3. 4. 5. Symptoms

Contributions to Information Technology The Hello World Collection Optimizing C and C++ Code Embedded software often runs on processors with limited computation power, thus optimizing the code becomes a necessity. In this article we will explore the following optimization techniques for C and C++ code developed for Real-time and Embedded Systems. Many techniques discussed here have roots in the material we covered in the articles dealing with C to Assembly translation. A good understanding of the following articles will help: Premature optimization is the root of all evil Donald Knuth wrote, "Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. In general, correctness and readability considerations trump code performance issues for most of your code. Adjust structure sizes to power of two Place case labels in narrow range Place frequent case labels first Splitting a switch statement

The 5 types of programmers « Steven Benner's Blog In my code journeys and programming adventures I’ve encountered many strange foes, and even stranger allies. I’ve identified at least five different kinds of code warriors, some make for wonderful comrades in arms, while others seem to foil my every plan. However they all have their place in the pantheon of software development. Without a healthy mix of these different programming styles you’ll probably find your projects either take too long to complete, are not stable enough or are too perfect for humans to look upon. The duct tape programmer The code may not be pretty, but damnit, it works! This guy is the foundation of your company. The OCD perfectionist programmer You want to do what to my code? This guy doesn’t care about your deadlines or budgets, those are insignificant when compared to the art form that is programming. The anti-programming programmer I’m a programmer, damnit. His world has one simple truth; writing code is bad. The half-assed programmer What do you want?

Free Books A lot of people keep asking about a good list of programming books. Hence, we are building this list to save your time and to spread the knowledge. Some of these books will definitely help us to evolve our coding skills and thought processes for developing better solutions. Meta-List Graphics Programming Language Agnostic: NerdDinner Walkthrough Assembly Language: Bash Advanced Bash-Scripting Guide See .NET below Django Djangobook.com Emacs The Emacs manual Thanks Emacser (October 17, 2010) Forth Git Haskell Dive Into HTML5 Java JavaScript Linux Advanced Linux Programming Lisp Lua Programming In Lua (for v5 but still largely relevant) Maven Mercurial NoSQL CouchDB: The Definitive Guide Objective-C The Objective-C Programming Language Parrot / Perl 6 Perl 6 (Work in progress) Perl PowerShell Mastering PowerShell Prolog PostgreSQL Practical PostgreSQL Python Learn REBOL Thanks Nick (October 19, 2010) Ruby Scala Scheme The Scheme Programming Language (Edition 4) Smalltalk Subversion SQL (Implementation agnostic) Symfony Vim

The Basics of C Programming" The previous discussion becomes a little clearer if you understand how memory addresses work in a computer's hardware. If you have not read it already, now would be a good time to read How Bits and Bytes Work to fully understand bits, bytes and words. All computers have memory, also known as RAM (random access memory). For example, your computer might have 16 or 32 or 64 megabytes of RAM installed right now. RAM holds the programs that your computer is currently running along with the data they are currently manipulating (their variables and data structures). Memory can be thought of simply as an array of bytes. float f; This statement says, "Declare a location named f that can hold one floating point value." While you think of the variable f, the computer thinks of a specific address in memory (for example, 248,440). f = 3.14; The compiler might translate that into, "Load the value 3.14 into memory location 248,440." The output that you see from the program will probably look like this:

Scripting Languages: PHP, Perl, Python, Ruby - Hyperpolyglot a side-by-side reference sheet sheet one: version | grammar and execution | variables and expressions | arithmetic and logic | strings | regexes | dates and time | arrays | dictionaries | functions | execution control | exceptions | threads sheet two: streams | asynchronous events | files | file formats | directories | processes and environment | option parsing | libraries and namespaces | objects | inheritance and polymorphism | reflection | net and web | gui | databases | unit tests | logging | debugging sheet two: streams | asynchronous events | files | directories | processes and environment | option parsing | libraries and namespaces | objects | inheritance and polymorphism | reflection | net and web | gui | databases | unit tests | logging | debugging version used The versions used for testing code in the reference sheet. show version How to get the version. php: The function phpversion() will return the version number as a string. python: import platform platform.python_version() ruby: <? pad

MR01001101 :: cryptography steganography resources and challenges

Related: