How does sprintf
work in the following programs?
if(p>=10000){
US>sprintf(str, "D:\\○○Research_Production Information Special Experiment_Nakayama_Succession\\System\\Final\\OpenCV-Sample001\\Lecture Image\\cap%05d.bmp",
} else {
sprintf(str, "D:\\○○ Laboratory_Production Information Special Experiment_Nakayama_Succession\\System\\Final\\OpenCV-Sample001\\Lecture Image\\cap%04d.bmp",p);
}
(opencv and tagio"tagio"tagio"tagio"tagio>)ed /c%2b%2b "rel="tag" title="View questions tagged with 'c++'">c++)
sprintf
in cis a function that outputs a formatted string to an array of char
.
https://msdn.microsoft.com/ja-jp/library/ybk95axf.aspx (mechanical translation)
https://linuxjm.osdn.jp/html/LDP_man-pages/man3/printf.3.html
(This should be easier to read)
The str
in the presentation code should be an array of char
defined like charstr[_MAX_PATH];
.
sprintf
format the string (in this example, %d
is stored in multiple characters where %d
is used to estimate and record teacher behavior during the lecture.
Note that backslashes in source code are escaped during compilation.
774RR has already answered in detail, but for beginners,
"Create a new string by combining values and strings stored in variables"
It is often used for this purpose.
© 2024 OneMinuteCode. All rights reserved.