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 Related:  general knowledge

Dennis Ritchie Home Page Location Dennis Ritchie Bell Labs, Rm 2C-517 600 Mountain Ave. Murray Hill, New Jersey 07974-0636, USA dmr@bell-labs.com +1 908-582-3770 (office), +1 908-582-5857 (fax) In Memoriam Dennis died in early October, 2011. As Dennis's siblings, Lynn, John, and Bill Ritchie--on behalf of the entire Ritchie family--we wanted to convey to all of you how deeply moved, astonished, and appreciative we are of the loving tributes to Dennis that we have been reading. Dennis was an unfailingly kind, sweet, unassuming, and generous brother--and of course a complete geek. We are terribly sad to have lost him, but touched beyond words to realize what a mark he made on the world, and how well his gentle personality--beyond his accomplishments--seems to be understood. Lynn, John, and Bill Ritchie History For many years, I worked in the Computing Sciences Research Center of Bell Labs. Soon after, Ken Thompson, together with me and others, first started work on Unix. Lucent and Alcatel merged as of Dec 1, 2006.

Processing.org Autotune.NET | Coding4Fun Articles We've all cringed as a hopelessly out of tune contestant appears on the latest episode of “American Idol.” Occasionally, there's a contestant who manages to be pitch perfect all the way through—right until they flub the final note. And in the cutthroat world of televised auditions, sing one slightly flat note and you're out. So what takes care of a bad-pitch day? Autotune—an effect that corrects the pitch of your voice so you'll never again sing out of tune. And now, with the power of modern microprocessors, autotune is possible in real-time, allowing singers to benefit from its almost magical powers during live concerts. The company most famous for its autotune effect is Antares. Here is a nerdy example of what Autotune can do. How does Autotune work? An autotune effect has two parts. The second stage is pitch shifting, or “correcting” a given note. Creating a .NET Autotune Algorithm For this project, we will be creating an autotune effect for .NET. Porting C++ to C# c#: VB.Net: VB.Net

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); } }

3 Ways To Speed Up The Windows 7 Shutdown Process Advertisement Ever since I switched to Windows 7 on my laptop, which had previously shut down within seconds while running on Windows XP, the slow shutdown has been nagging me. If you also happen to be looking for ways to kick-start a Windows 7 slow shutdown, look no further! Here I will introduce you to 3 ways to optimize or speed up the logoff process, so that you can leave the office or get into bed faster. Prologue I tested these tips one after the other on my Windows 7 netbook (which shut down significantly faster after upgrading to 2GB RAM). Initial shutdown time on test machine: 32 seconds 1. Before Windows shuts down, it attempts to properly close all running processes. These are two fairly harmless registry hacks. Editing the registry can damage your operating system! For the first hack, click the key combination > [WINDOWS] + [R], type > regedit into the text field, and click > OK to launch the registry editor. In the registry editor, navigate to this folder: 2. 3. Epilogue

E. W. Dijkstra Archive: A parable. (EWD 594) (Recently I found the following text in manuscript among old papers of mine. It must have been written in the middle of 1973, but I don't think that in the intervening three years it has lost anything of its significance. Hence I now incorporate it in the EWD-series.) A parable. Years ago a railway company was erected and one of its directors —probably the commercial bloke— discovered that the initial investments could be reduced significantly if only fifty percent of the cars would be equipped with a toilet, and, therefore, so was decided. Shortly after the company had started its operations, however, complaints about the toilets came pouring in. In order to solve the problem, a bit of information was associated with each car, telling whether it was a car with or without a toilet, and the shunting yard was instructed to compose trains with the numbers of cars of both types as equal as possible. I have told the above story to different audiences. transcribed by Corrado Cantelmi revised

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.

Free Programming and Computer Science Books 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 Learn Regex 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

Temporary Email Aliases After running tempalias.com as a fun project for a bit more than a year and a half, I would say that the experiment is now finished and tempalias.com is down for now. There are both personal and technical issues. Let me list them here: the tempalias codebase relies on a very old version of node.js and some very old additional libraries which wouldn't even work with newer versions of node.js. This means that tempalias.com is down for now. If you want to have a service like this, remember that the source code of tempalias.com is freely available at my github page I hope you undestand

An Interview by a Seventh Grader June 2010 (A seventh grader sent me these interview questions for a school project.) 1. What are some qualifications of a computer programmer? Programmers tell computers what to do—not in a human language like English but in special unambiguous languages called programming languages. 2. For me the best part is building things. For me the worst thing about programming is dealing with external constraints. What's most challenging about being a programmer depends on how good you are. 3. The range is very wide, because some programmers start their own companies and if these companies succeed they can make a lot. 4. This varies so much that there's no one answer. Interruptions are very bad for programming, so people who spend a lot of time programming often do it at times when they'll be left alone, like late at night or early in the morning. 5. Programming is something you learn by doing. (This is true for most fields, actually, not just programming.) 6. 7. 8. 9. 10. 11.

Programming Methodology - Download free content from Stanford Hallmarks of a Great Developer - Test Guide If you ask me, I'll tell you a great developer Plans before coding A great developer takes the time to plan an approach before designing or coding. A great developer knows that the time required to do so will be more than paid back by the time saved by getting it more right the first time. A great developer plans all scales of work, from envisioning multiple versions of a product to writing or modifying a small method. Always knows why A great developer always knows exactly why they wrote a particular line of code, and why they wrote it the way they did. Writes situation-appropriate code Any developer can write code. Deviates where and when necessary A great developer not only knows the canonical implementation but understands it is the canonical implementation. Knows when not to change code A great developer knows that changing code is sometimes worse than fixing it. Approaches debugging scientifically A great developer knows that debugging is a science not an art and approaches it as such.

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

Related: