i find the easiest way to know the sharps & flats in a key is to remember that there are never the same letter (A-G) twice in a key.
meaning all keys have an A B C D E F G.
The key of C Major is easy, no sharps or flats.
the next key (clockwise in the circle of 5ths) is G Major with one sharp. So start with G and write the letters out, G A B C D E F.
Next you have to remember that a Major key has an interval pattern, 2 Whole steps, 1 half step, 3 whole steps, 1 half. or W W H W W W H.
So start w G, whole step to A, whole to B, half to C, whole to D, whole to E, whole to (either F# or Gb), half to G (next octave)
So since you can't have a G and Gb in the key, (same letter) the proper denotation for writing the key is to use F#.