The biggest struggle for me both when I started going to school for computer science and when I started my career as a computer programmer really didn't have anything to do with writing software itself. My biggest struggle was with how hard some problems are to solve and not getting discouraged when I had a hard time solving them. I still struggle with this today, but I've come up with some tricks that get me through the really difficult challenges I face at work.
I treat every challenge like a maze. It's possible to get out of any maze just by using your hand. If you keep walking with your hand touching the wall and never letting go, you'll eventually find the exit. It may not seem like that has anything to do with computers, but it did teach me something about problem solving and problem solving is what I do almost every day as a software engineer.
When I'm trying to solve a problem, I try to have a method for solving that problem. I break the problem down into smaller pieces, and I look at each of those pieces one at a time. It's like if you come to a branch in a maze and you have to turn right or left: if your left hand is on the wall, then you'll have to turn left first. You'll follow that until you hit a dead end, and because your hand is on the wall you'll be forced turn around and retrace your steps until you go back to the branch and take the other path.
If you get discouraged by a problem, just remember how good it will feel when you eventually solve it, and keep working until you do solve it. And always remember: if you get stuck, you can always ask for help.