所以,我试图编写一个程序,生成SQL插入命令句子,并将它们写入.txt
文件。开始时,我只写了一小段代码,它只将一个插入开始写入命令:表名和列名。fstream error:'wrf <<“中的'operator <<'不匹配''插入''|
#include <iostream>
#include <iomanip>
#include <stack>
#include <queue>
#include <fstream>'
using namespace std;
ifstream wrf;
int main()
{
queue<string>row1;
queue<string>row2;
queue<string>values;
// queue<void>storeValues;
string table;
int columnVal;
int valuesVal;
string insertQ = "insert into";
string valQ = "values";
string columnName;
cout << "Insert table name: ";
cin >> table;
cout << "Number of columns: ";
cin >> columnVal;
int temp = columnVal;
cout <<"------------------------------\nStulpeliai:\n";
//------------------------------
while(temp)
{
cin >> columnName;
row1.push(columnName);
temp--;
}
//int temp2 = valuesVal;
wrf.open ("DB.txt");
cout << "\n------------------------------\nTEST\n";
cout << insertQ << table << "\n\t(";
wrf >> insertQ >> table >> "\n\t(";
while(row1.size() != 1)
{
cout << row1.front() << ", ";
wrf >> row1.front() >> ", ";
row2.push(row1.front());
row1.pop();
}
cout << row1.front() <<") ";
wrf >> row1.front() <<") ";
row2.push(row1.front());
row1.pop();
wrf.close();
return 0;
}
出于测试的原因,我试着写ifstream
句子来测试它是如何写入.txt
文件,但我碰上了,没有匹配错误...
有什么想法?
P.S.我只是为了学习的原因而使用队列。我希望问题足够全球化。
的问题是,没有一个运营商的工作。我尝试过,但不是或它们工作,相同的错误,所以当问题的根源在哪里?\ –
你想用'wrf >> insertQ >> table >>“\ n \ t(” ;'? – MokaT
我试图添加一个字符串“insert into”和一个表名。 –