difference between sprintf and strcpy ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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 Answers
+ 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