Don't worry! Everyone has a friend code!
On the home page of the 3DS, at the top there is an orange smiley face in a square box. Click that. This will take you to a list of friends that you already have, as well as your much-yearned for friend code.
How to add people?
You can add people locally or through the internet. If you want to add someone locally (close by), have you and your friend touch the 'Local' button and sooner or later you will both be registered.
If you want to add people via the internet, click the 'Internet' button and you will need to manually insert their friend code. :)
If you want to add the person you battled/traded/whatevered with, it has to be an Acquaintance. You might not be able to register your friend possibly because the person you requested didn't want to be your friend.
Hope I helped. :)
Source and Experience