I'm 22 and recently graduated with a degree in Computer Science from a second-rate Canadian University. Two years into my program I went through this same phase but my GPA has never been very strong and transferring was just not a realistic option.

Actually ~10 hours ago I was just reminiscing/reflecting on the experience and my achievements of the last 4 years. It's been 3 days after convocation and one of my good buddies is continuing on with his studies while I am diving into the wonderful world of work. I woke up and read this thread during breakfast so this a happy coincidence. I hope that someone can benefit from my experience/mistakes.

If your goal is to get into a prestigious University then I have some bad news. It is much easier, (less competitive) and cheaper (courses cost money) to get your foot in the door through high school than it is to transfer in. That being said, if you are highly determined and put in the effort you will find a way to get in. *

Yesterday evening I was fiddling around with http://www.cs.utep.edu/admissions/ . Graduate school has never been a priority for me so I would recommend doing your own research but understand that you -need- a strong GPA, especially in your CS courses. Normally I don't recommend comparing your personal development with that of your peers but it's a competitive world and a 3.3+ GPA, high GRE scores, and research experience seems to be the prerequisite for any respectable CS school these days.

As for grades I share the same sentiment as the fellow here. http://www.stanford.edu/~pgbovine/grades.htm Looking at the graduating class and having worked with many of my peers directly I will tell you now that there is a very strong correlation between those with strong mathematical ability and good grades. But even if you don't have the aptitude * grades reflect how well you perform what is required for a class so hard work, collaboration, and even collusion can skew results significantly. Research experience is easy to get because professors are always looking for bright students. The pay will not be very good (it's typically minimum wage where I studied) but it's more for the experience and now you can double dip and add two bullet points for your resume: One for work experience and another for a scholarship. Once again, GPA is one of the prime determinant for these research programs. (the other is finding a professor to sponsor you)

I would have liked to keep the door to graduate studies open, but I failed 3 courses in a 40 course program which is pretty devastating to anybody's GPA. (I used up nearly all my withdrawals in my first year after a stint in another faculty, but that's another story) A cumulative total of 2.99998 is not competitive for CS graduate studies. I've secured a fairly plum job which is my motivation for getting a degree but obviously I've burned some bridges. I try not to look back but for now I wonder how my life would be different if I spent more time on my studies and less programming.

tl;dr You know where you want to go. Find out how to get there. Put in the effort and you will likely achieve your goal. I'll be happy to elaborate more on my experience if you are interested but I recommend speaking with your TA's and professors. They've been there, done that and will be able to offer sound advice. Phil also has more to say about grad school but Stanford is probably more selective than most. http://www.stanford.edu/~pgbovine/grad-school-app-tips.htm

* A disproportionately large proportion of freshman think they are going to get double degrees, get into graduate studies or whatever. Most inevitably end up changing their minds.

* You'll know when you expend three times as much effort/time in Graphics programming than your friend, brilliant as he may be. Also many of the "distinguished" students that graduated with honors have minors in general or pure mathematics.

EDIT: Edited for grammar and coherency.