0
我有以下代碼:傳遞字符串
#include <stdio.h> // For printf()
#include <sys/stat.h> // For struct stat and stat()
struct stat stResult;
if(stat("Filename.txt", &stResult) == 0)
{
// We have File Attributes
// stResult.st_size is the size in bytes (I believe)
// It also contains some other information you can lookup if you feel like it
printf("Filesize: %i", stResult.st_size);
}
else
{
// We couldn't open the file
printf("Couldn't get file attributes...");
}
現在。我如何通過stat()傳遞自己的字符串?像這樣
string myStr = "MyFile.txt";
stat(myStr, &stResult)