That song - and thousands of others, can and still will be in key C, even though there's an F&sharp; note in there somewhere.
I suspect it comes just before a G note, and what's happened is that the song's modulated briefly, sort of visiting key G, but not moving permanently into key G. It probably wanders back to all key C notes soon after.
This sort of thing happens a lot, but
just becasuse there's a non-diatonic note in there, doesn't mean a change of key.
That would be deemed so if the piece stayed with that F&sharp; for many, many bars.
Tink of it this way
- if you changed the key signature to one sharp, soon, you'd have to keep putting natural signs for the remaining F notes, and that wouldn't be right.
Seeing a sharp sign before any F notes, in key C, tells us 'modulation'.
music.stackexchange.com/users/2808/Tim
Sure, that's not a problem.
As another example, O Canada , when rendered in C major, would have four F♯s in it.
X:
1T:
O CanadaM: CL: 1/8
K: CmajE4G3G|C6D2|E2F2G2A2|D6z2|E4^F3F|G6A2|B2B2A2A2|G6
music.stackexchange.com/users/1941/200_success
The examples so far all include a modulation, so that the F# occurs while the chord is G.
But it's very possible to get an F# even when the chord is still C. For example: ‘ Maria ’ from West Side Story .
The second, fifth, and eighth notes in the melody are all F# against a C chord (and several more later on).
(The same three notes recur at the start of ‘Cool’, from the same show.)
As many others have said on this site: there are no hard-and-fast rules in music, only guidelines* — and if non-scale notes seem right to you, by all means use 'em!
(* It's worth understanding the rules/guidelines and the reasons for them before you break them.
But just as the Rule Of Funny (warning: TVTropes) trumps just about everything else when it comes to humour, so the ‘rule of sounding good’ trumps just about everything else in music!)
music.stackexchange.com/users/56549/gidds
Depends.
Here are examples from two very well-known pieces (bonus points for identifing them :-)
one of a &sharp;4 that definitely is just decorative, not a modulation, and one that is a modulation.
Which category does yours fall into?
If in doubt, show us the piece.
music.stackexchange.com/users/17003/Laurence Payne
Like Tim explains and Lawrence shows ...
your song seems to have a momentary modulation (maybe 1-2 bars) to the dominant G (V = 5th degree).
This is managed by the D7, dominant (V) of G, called secondary dominant.
This chord is built by D,F#,A,C, where F# is the leading tone to G. V7 of V in C : The term secondary dominant refers to a triad or seventh chord built on the dominant, the fifth scale degree, set to resolve to a scale degree other than the tonic, with the dominant of the dominant (written as V/V or V of V)
Wiki
You will find a lot of more information about secondary dominants in this SE-site or here:
https://en.wikipedia.org/wiki/Secondary_chord can I still say the song is in C major?
Or, does it change the key of the whole song?
I don't think the song is changing the key.
Probably not!
It depends of the continuation.
F# can also be a chromatic approach to G or a passing tone to F
e.g. you are writing a Blues!
music.stackexchange.com/users/56219/Albrecht Hügli
It's not necessarily (in fact, not likely) what you're seeing in your example, but a piece with a tonal centre of C but frequent occurrences of F♯ could be in a C Lydian Mode.
The Lydian mode is the mode based on
F. So if you played all the white notes on a piano starting on F, you would be playing an F Lydian mode.
More generally, it is equivalent to a major scale with a sharpened 4th.
Maria, from West Side Story , which is mentioned in another answer, has sometimes been analysed as being in Lydian mode.
music.stackexchange.com/users/61534/Jim Cullen
If you're getting to the F# directly from the C (or playing it over a C bass), then that dissonant interval is called a "tritone" (3 whole notes put together).
https://en.wikipedia.org/wiki/Tritone
It's a very common idiom to use tritones to lead up to the fifth (or sometimes down to the fourth).
As other answers have mentioned, the eponymous melody in "Maria" from West Side Story is one canonical example that people use to hear the interval in their mind's ear.
However, it's possible for an F# to be played in a section of your key-of-C song that's over a G chord, in which case it wouldn't be dissonant (although that still wouldn't change the key of the whole song).
It all depends on how the note is placed in the context of the song.
music.stackexchange.com/users/None/
I've composed a melody in C Major but there's this one note, F#, which comes at two places. So, can I still say the song is in C major? Or, does it change the key of the whole song?
Song in C major has F# note
music.stackexchange.com
<scales>
music.stackexchange.com/questions/90348
music.stackexchange.com/users/63543/Indu
This chord is built by D,F#,A,C, where F# is the leading tone to G.  V7 of V in C : The term secondary dominant refers to a triad or seventh chord built on the dominant, the fifth scale degree, set to resolve to a scale degree other than the tonic, with the dominant of the dominant (written as V/V or V of V). However, it's possible for an F# to be played in a section of your key-of-C song that's over a G chord, in which case it wouldn't be dissonant (although that still wouldn't change the key of the whole song).  It all depends on how the note is placed in the context of the song.
This chord is built by D,F#,A,C, where F# is the leading tone to G. It's possible for an F# to be played in a section of your key-of-C song that's over a G chord. It all depends on how the note is placed in the context of the song.