When I run this code in visual studio I get the right output: The correct output looks like:
But when I run the same code in hopper (unix) I am getting some weird output.. it looks like this:
the code is below:
//#include <mysql.h>
#include <iomanip>
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <conio.h>
using namespace std;
int main()
{
//connect= mysql_init(&mysql);
//connect= mysql_real_connect(&mysql,SERVER,USER,PASSWORD,DATABASE,0,0,0);
cout<<endl;
ifstream inFile;
ofstream outFile;
inFile.open("team.txt");
if (inFile.fail())
{
cout<<" ***ERROR*** File not found ***ERROR*** "<<endl;
//exit(1);
}
else
{
string sqlQuery2;
int numOfLines=0;
while(!inFile.eof())
{
numOfLines++;
string line;
getline(inFile,line) ;
int y = line.length();
string nums,city,conf,name;
int count=0;
for(int x=0;x<y;x++)
{
if(line[x]!=':' && count==0)
{
nums+=line[x];
}
else if(line[x]!=':' && count==1)
{
city+=line[x];
}
else if(line[x]!=':' && count==2)
{
conf+=line[x];
}
else if(line[x]!=':' && count==3)
{
name+=line[x];
}
else if (line[x]==':')
{
count++;
}
}
sqlQuery2="INSERT INTO team VALUES ("+nums+",'"+city+"','"+conf+"','"+name+"');";
cout<<sqlQuery2<<endl;
//mysql_query(connect,sqlQuery2.c_str());
}
}
inFile.close();
_getch();
return 0;
}