Advertisement
4_2005-2006 Graphics/ Sound #154940

Lewies Validation Code Image - Part 2

Prevent content and processes from being misused for spam or inappropriate use. An image is displayed to the end-user. An attempt is made to prevent OCR recognition by agents, spiders, or artificial intelligence to gain access to content or processes. The image will display a “code” to the user that they are required to enter into a field provided.

AI

AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

소스 코드
original-source
Upload
<BR>
Somebody asks me how to do something like this,
<BR>
so I'm posting it. Basically, its a function like 
<BR>
printf, that can take a variable number of 
<BR>
arguments, using the (...). I use something like 
<BR>
this to create a string for my graphics programs, 
<BR>
and draw the resulting string to the screen.
<BR>
<BR>
// Create a string function
<BR>
void CreateAString(const char *format, ...)
<BR>
{
<BR>
 va_list list;
<BR>
 char string[1024];
<BR>
<BR>
 // Create the string from the parameters
<BR>
 va_start(list, format);
<BR>
 vsprintf((char *)string, format, list);
<BR>
 va_end(list);
<BR>
<BR>
 // Function to draw the string goes here
<BR>
}
<BR>
<BR>
Now, the complete string is stored in 'string'. 
<BR>
To use this function, you can use something like:
<BR>
<BR>
void function()
<BR>
{
<BR>
 int num1 = 10, num2 = 20;
<BR>
 CreateAString("NUM1 = %d NUM2 = %d", num1, 
        num2);
<BR>
}
<BR>
<BR>
And 'string' would be:
<BR>
<BR>
NUM1 = 10 NUM2 = 20
<BR>
<BR>
Pretty easy. Not used real often, but it can be useful.
원본 댓글 (3)
Wayback Machine에서 복구됨