+ 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
5 RĂ©ponses
+ 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