Hi guys I'm writing a program that reads NMEA sentences for a university assignment and I'm having trouble with segmentation fault. Can anyone help me fix it, please?
NmeaSentence::NmeaSentence(std::string sentence) {
const char *temp = sentence.c_str();
char *c_sent;
strcpy(c_sent, temp);
char *pch;
for(int i = 0; i < MAX_SENTENCE_PARTS; i++){
pch = strtok(c_sent, ",");
this->sentenceParts[i] = pch;
}
this->sentence = sentence;
this->sentenceType = sentenceParts[0];
}
The error seems to be happening at strcpy. What am I doing wrong?