小编Bry*_*ong的帖子

比较两个char*是否相等

可能重复:
比较两个C风格字符串的正确功能是什么?

我的比赛条件不起作用!有人可以建议如何比较C风格的字符串?

void saveData(string line, char* data){
    char *testString = new char[800];
    char *stpr;
    int i=0;
    bool isData=false;
    char *com = data;
    strcpy(testString,line.c_str());
        stpr = strtok(testString, ",");
        while (stpr != NULL) {
            string temp = stpr;
            cout << temp << " ===== " << data << endl;
Run Code Online (Sandbox Code Playgroud)

尽管tempdata比赛,以下条件不工作:

if (stpr==data) {
  isData = true; 
}
Run Code Online (Sandbox Code Playgroud)

不确定这是否有帮助.该SaveData()函数从以下函数调用:

void readFile(char* str){
    string c="", line, fileName="result.txt", data(str);
        ifstream inFile;
    inFile.open(fileName.c_str());
    resultlist.clear();

    if(inFile.good()){    
        while(!inFile.eof()){
            getline(inFile, line);
            if(line.find(data)!=string::npos){ …
Run Code Online (Sandbox Code Playgroud)

c++ c-strings

10
推荐指数
2
解决办法
5万
查看次数

Shell Scripting中的布尔值

我有一个boolean for while循环的问题.因此,我切换到for循环.但是,在满足条件后,我无法更改布尔值.

doFirst= true
    for (( j=1; j<=7; j++))
    do
            letter="A"
            seatChoses=$letter$j

            flagRand=$(echo $flightSeatBooked | awk -v flseatRand=$flightSeatBooked -v orseatRand=$seatChoses '{print match(flseatRand, orseatRand)}')
            if  $doFirst ; then
            **$doFirst= false** // Here is the error!
                if [ $flagRand -eq 0 ]; then
                    echo "System generated a slot, "$seatChoses" for you. [Y or N]"
                fi
            fi

    done
Run Code Online (Sandbox Code Playgroud)

shell

7
推荐指数
1
解决办法
3万
查看次数

从矢量对中获取值时出错

在对向量的迭代器中访问对的值时,为什么会出现以下错误?

vector< pair<int,string> > mapper;
if(Hash(input, chordSize) != id){
    mapper.push_back(make_pair(tmp, input));
}

for (vector< pair<int,string> >::iterator it = mapper.begin(); it != mapper.end(); ++it)
{
    cout << "1st: " << *it.first << " "           // <-- error!
         << "2nd: " << *it.second << endl;        // <-- error!
}
Run Code Online (Sandbox Code Playgroud)

错误信息:

main_v10.cpp:165:25:错误:'std :: vector >>> :: iterator'没有名为'first'main_v10.cpp的成员:165:56:错误:'std :: vector >>> :: iterator'有没有名为'second'的会员

我怎样才能解决这个问题?

c++ iterator vector

5
推荐指数
1
解决办法
5827
查看次数

Glyphicon Bootstrap v3未加载

我下载了最新的Bootstrap v3文件并导入了bootstrap.min.css.但我永远无法使用Glyphicon图标.我很确定我的CSS是对的.下面是我的HTML.为什么?

<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
Run Code Online (Sandbox Code Playgroud)

javascript css twitter-bootstrap glyphicons twitter-bootstrap-3

2
推荐指数
1
解决办法
1027
查看次数

sql连接

我可以连接下面的查询吗?如果不是,我该怎么办?我不想读取行,$retrieveUnitExist因为它浪费了另一步.

$retrieveUnitExist = "SELECT unitid FROM ESTATEUNIT WHERE BLOCK = 1";
$insertAddress = "INSERT INTO ADDRESS (value1, value2) VALUES ('1','".$retrieveUnitExist."')";

mysqli_query($conn, $insertAddress);
Run Code Online (Sandbox Code Playgroud)

php sql

0
推荐指数
1
解决办法
339
查看次数