Hello All,
This question is a part of the question I had previously posted:
[
Inconsistent file format[
^]] , but this is particularly about swscanf_s function.
In the code :
CStdioFile std;
CString buffer;
wchar_t str1[2046],str2[2046],str3[2046],str4[2046],str5[2046],str6[2046];
double time, lat;
if (std.Open(fname, CFile::modeRead)) {
while (std.ReadString(buffer) )
{
int out = 0;
out = swscanf_s(buffer, (_T("%[^,],%lf,%lf,%[^,],%lf,%[^,],%d,%d,%lf,%lf,%[^,],%lf,%[^,],,%[^,]"),
if(out = 15)
{
}
else
}
Since the file is not always of the same format, some files may have more than 3 variable or less. So I used a method to use in the swscanf_s, such that it returns a string.
i.e;
SetValues()
{
wchar_t str1[2046];
double time, lat;
CString fmtStr;
fmtStr.AppendFormat((_T("%[^,],%lf,%lf,%[^,],%lf,%[^,],%d,%d,%lf,%lf,%[^,],%lf,%[^,],,%[^,]"),
return fmtStr;
}
And use this function in the swscanf_s function. Like this :
out = swscanf_s(buffer, SetValues();
But I get an error that says:
Expression: ("Incorrect Format specifier", 0)
The input file format looks like this: $GPS1,145217.00,7434.7369647,N,05713.8922390,W,2,09,0.9,44.94,M,21.98,M,43.2,0081*55
Need some help please