#include<iostream>
#include<fstream>
#include <cstring>
#include <deque>
#include <vector>
#include <functional>
using namespace std;
// TYPES
struct CtrCdl
{
long ntp;
string Time;
double Px;
double vol;
};
// GLOBALS
CtrCdl xz;
int lnum;
int main(){
int n;
vector <string>v;
v.push_back( "QTRZZPL");
v.push_back( "F");
v.push_back( "09:30:28");
v.push_back( "250.23");
v.push_back( "100");
v.push_back( "+");
string Qtz;
string QtSy;
Qtz = v[0].substr(0,3);
QtSy=v[0].substr(3,10);
if (strcmp(Qtz,"QTU")==1){
xz.ntp=lnum;
xz.Time= v[2];
xz.Px=atof(v[3]);
n=1;
}
return n;
===============
assignment of px fails and strcmp(Qtz,"QTU") does not compile
strcmp(Qtz,"QTU")
Qtz
is an object of type string. strcmp takes two arguments of type char*. A string is not a char*.
atof(v[3])
v[3]
is an object of type string. atof takes one argument, of type char*. A string is not a char*.
Last edited on
Thank You!s it took me while to fix this
I changed xz.Px=atof(v[3].c_str());
similarly if (strcmp(Qtz.c_str(),"QTU")==0)
Now it compiles -Thank you!
You could write
if ( Qtz == "QTU" )
instead of
if (strcmp(Qtz.c_str(),"QTU")==0)