简体   繁体   中英

sprintf, printf and format specifiers

I'm having trouble understanding what this line of code does:

    sprintf(obj, "%s.o", root);

obj and root are both character buffers, from what I read root is basically copied to obj? I'm not sure what "%so" is doing. %s is to specify a String but the .o?

thanks for any help

The %s will be replaced with the contents of root , and followed by the .o part of the string, which is just an "additional" text. For example, if root has "file", obj will be set to "file.o".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM