difference between sprintf and strcpy ? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 6

difference between sprintf and strcpy ?

when i used strcpy and sprintf to assign a value to an array in my struct i got the same output i coudn't notice any difference, does one of them have a hidden feature ? this is the code ā¬‡ļø https://code.sololearn.com/cZVCpjSertLc/?ref=app

14th Aug 2021, 2:57 AM
ox titanium
ox titanium - avatar
4 Respostas
+ 3
sprintf is printf for string. Everything you can do with printf can be achieved with sprintf. example: sprintf(name, "%s %s", first_name, last_name); strcpy just copies string to the other.
14th Aug 2021, 7:22 AM
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ - avatar
+ 1
Thanks Martin .. it helped :)
14th Aug 2021, 9:45 PM
ox titanium
ox titanium - avatar
0
I don't know anything about the differences, except that fact that sprintf allows string formatting.
14th Aug 2021, 4:54 AM
Calvin Thomas
Calvin Thomas - avatar
0
Thanks carrie
14th Aug 2021, 7:38 AM
ox titanium
ox titanium - avatar