[英]how will i pass the path of a file name to void *buffer using c language?
implementing ProcessRequest and wants to copy data into buffer to return to the caller实现 ProcessRequest 并希望将数据复制到缓冲区以返回给调用者
The function signature is he following :函数签名如下:
int ProcessRequest(HCST hCST, void *buffer, short tag, short status)
path name of the file is stored in char src [40]
;文件的路径名存储在
char src [40]
;
You need this :你需要这个 :
int ProcessRequest(int hCST, void *buffer, short tag, short status)
{
// stub function
static char test[] = "Test";
strcpy(buffer, test);
return 0;
}
...
char src [40];
...
ProcessRequest(myhCST, src, mytag, mystatus);
/* now src contains "Test" */
This code is very simple and unsafe because ProcessRequest
doesn't know the size of buffer
and hence may potentially overwrite past the end of buffer
.这段代码非常简单且不安全,因为
ProcessRequest
不知道buffer
的大小,因此可能会在buffer
结束后覆盖。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.