I want to add a electrical outlet by using the wiring in a switch box. The switch has three wires and the power comes from the ceiling. The wire are black white and red
If the box has a black, white and red conductor only, more than likely it's a 3 way switch. If the light it switches on can be turned on from another location, it's a 3 way switch. It also means you don't have the wires necessary for an outlet. You are missing a neutral wire( normally the white wire). The white wire in your case is used as one of two "traveler" conductors or the switch leg.