Copies a string literal or string variable to another string variable.
strcpy and string assignment with = copy at initialization only. Use strcpyk to copy a string during performance.
Syntax
Sdst=strcpy(Ssrc)Sdst=Ssrc
SdststrcpySsrcSdst=Ssrc
Initialization
Ssrc -- the source string, given as a literal or a string variable.
Sdst -- the destination string variable. It receives a copy of the source. Later changes to the source leave this copy unchanged.
Examples
These examples copy a literal into a source variable, then copy it with both strcpy and =. They change the source and print all three strings. They run without audio output or external files.
<CsoundSynthesizer><CsOptions>-n -d -m0
</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=10dbfs=1instr1; Copy a literal, then copy that variable to two destinations.source:S=strcpy("Hello, world!")copied:S=strcpy(source)assigned:S=source; Changing the source leaves both copies unchanged.source=strcpy("Goodbye.")prints("Source = %s\n",source)prints("Copy = %s\n",copied)prints("Assignment = %s\n",assigned)endin</CsInstruments><CsScore>i100.1e</CsScore></CsoundSynthesizer>
<CsoundSynthesizer><CsOptions>-n -d -m0
</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=10dbfs=1instr1; Copy a literal, then copy that variable to two destinations.Ssourcestrcpy"Hello, world!"ScopystrcpySsourceSassigned=Ssource; Changing the source leaves both copies unchanged.Ssourcestrcpy"Goodbye."prints"Source = %s\n",Ssourceprints"Copy = %s\n",Scopyprints"Assignment = %s\n",Sassignedendin</CsInstruments><CsScore>i100.1e</CsScore></CsoundSynthesizer>