无限循环中的分段错误

所以我用LCD显示器运行DS18S20。

我正在测量我的房间Tmp并将其显示在LCD上。

在所说的无穷循环中,我在运行5-6次后得到错误“细分错误”。我读到它必须是一个变量,并在我的getTmp()函数中得到了怀疑,但不知道如何解决它。

我现在学习c ++已有两个星期,需要您的帮助。

提前输入。

我的代码:

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <wiringPi.h>
#include <lcd.h>
#include <unistd.h>
using namespace std;
#define ever (;;)
//USE WIRINGPI PIN NUMBERS
#define LCD_RS  25               //Register select pin
#define LCD_E   24               //Enable Pin
#define LCD_D4  23               //Data pin 4
#define LCD_D5  22               //Data pin 5
#define LCD_D6  21               //Data pin 6
#define LCD_D7  14               //Data pin 7
void getTmp(string* y){
    ifstream file("/sys/bus/w1/devices/10-00080366745a/w1_slave");
    string f[2];
    if(file.is_open()){

        for(int i = 0; i<2;++i){
            getline(file, f[i]);
        }
    }
    string s = f[1];
    bool x = true;
    int i3 = 0,i2 = 0;
    while(x){
        if(i2 <= 4 && i2 > 0){
            y[i2-1] = s[i3];
            ++i2;   
        }
        if(i2>4){
        x=false;
        }
        if(s[i3] == '='){
            i2 = 1;
        }
        ++i3;
    }
}

int main(){
    unsigned int microseconds = 5000;
    string b [4];
    string* y= b;
    int lcd;
        wiringPiSetup();
    const char *tmp ;
        for ever{
    getTmp(y);
    string t = "Temp = "+b[0]+b[1]+"."+b[2]+b[3]+"°C";
    tmp=t.c_str();
    lcd = lcdInit (2, 16, 4, LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7, 0, 0, 0, 0);
        lcdPuts(lcd, tmp);
    cout << tmp << endl;
    usleep(microseconds);
    }
    return 0;
}