Note that I'm Taiwanese and I use Traditional Chinese characters. The swear words I type below (sorry!) may look different in Simplified Chinese. Also, China has way more swear words than us that I don't understand.
...for swear words, do they use the same character they use for the word or is it written differently?
As many people have written above, the three most common swear words look exactly the same as normal words.
Addressing your mother (or nobody's mother in particular) 媽的 (`ma1de5`) looks quite harmless. I have said this many times by pure accident because I address other people's mothers with one 媽 contrary to two (媽媽).
操 `cao4` is synonymous with the F-bomb. It is usually pronounced `cao1` and used as a verb (to exercise extraneously) or in a phrase like 操場 (`cao1chang3`, meaning track field).
幹 `gan4` is used with 幹什麼 `gan4shen2me3` and 幹事 `gan4shi4`. It's a verb meaning "to do". The sexual innuendo is the same as the English equivalent. `gan4` only becomes a swear word when it's on its own.
Also maybe describe a experience that you accidentally said a swear word in Chinese.
Here's a little story my uncle told me...the times may have changed since that was 5 years ago, but..:
When you go to China, never call the waitress 小姐 `xiao3jie3` ("Miss" in English). Apparently in China, 小姐 refers to prostitutes... You have to call them 同志 `tong2zhi4`, or "comrade". In Taiwan, 小姐 is a common term for just about any girl you meet.