I am working on the data collection, and trying to scan the title and convert that into real number,using "sscanf", but It did not give me the number as I expect, the "split function" which is wrote, is helping me to split out string vector:
#include <iostream> // std::cout
#include <string> // std::string, std::stod
int main() {
string fn = "ch-683-mhz-8000.0-ksps-2016-06-20-17.24.19-utc.dat";
vector<string> v;
int f0, fs;
split(fn, '-', v);
for (int i = 0; i < v.size(); ++i) {
cout << i << " " << v[i] << '\n';
}
for(unsigned i=1; i < v.size(); i++){
if(v[i] == "mhz"){
std::sscanf(v[i-1], &f0);
int ret = sscanf(v[i-1], &f0);
cout << v[i-1] ;
}
}
return 0;
}
the "vector v " will give me the result: 683 mhz 8000.0 ksps 2016 06 20 17.24.19 utc.dat
and I want to convert 683 and 8000 into real number, but I received error, even i tried to do some search from the forum:
Description Resource Path Location Type
'resize' is ambiguous '
Candidates are:
void resize(unsigned long int, std::complex<float>)
' fft.hpp /test2/src line 186 Semantic Error
recipe for target 'src/test2.o' failed subdir.mk /test2/Debug/src line 18 C/C++ Problem
'resize' is ambiguous '
Candidates are:
void resize(unsigned long int, std::complex<float>)
' fft.hpp /test2/src line 251 Semantic Error
cannot convert ‘std::__cxx11::basic_string<char>’ to ‘const char*’ for argument ‘1’ to ‘int sscanf(const char*, const char*, ...)’ test2.cpp /test2/src line 495 C/C++ Problem
cannot convert ‘std::__cxx11::basic_string<char>’ to ‘const char*’ for argument ‘1’ to ‘int sscanf(const char*, const char*, ...)’ test2.cpp /test2/src line 494 C/C++ Problem
Invalid arguments '
Candidates are:
int sscanf(const char *, const char *, ...)
' test2.cpp /test2/src line 494 Semantic Error
Invalid arguments '
Candidates are:
int sscanf(const char *, const char *, ...)
' test2.cpp /test2/src line 495 Semantic Error
make: *** [src/test2.o] Error 1 test2 C/C++ Problem
Could any one help?
Thank you so much.