我希望用字符','分割一个“字符串”。该字符串包含一个 GPS NMEA 编码字符串,但这无关紧要。
我的问题是,有时处理这个 char 数组的函数的参数是空的......就像数组中没有任何东西一样。
我应该如何正确地将“char string[]”传递给一个函数,以便我可以在发送它时对那个参数进行操作(作为一个 char 数组,而不是一个指向数组的 char 指针)。
我还需要指定我正在使用 mikroC 进行 PIC。
这是我现在的代码:
char* GPS_sateliti;
char CsatInView[] =
"$GPGSV,3,2,11,14,25,170,00,16,57,208,39,18,67,296,40,19,40,246,00*74";
GPS_sateliti = GrupeazaDupaVirgule(CsatInView, 2);
char* GrupeazaDupaVirgule( char deGasit[],int nrVirgule ){
int cVirgule = 1;
char* pch = strtok (deGasit,",");
while (pch != 0)
{
pch = strtok (0, ",");
cVirgule++;
if(nrVirgule == cVirgule){
break;
}
}
return pch;
}
对在调试模式下作为参数接收的char数组进行操作的函数,在进入函数之前char数组是可以的,进入之后,它似乎是空的
可能我应该收到一个指向字符数组的指针?欢迎任何形式的建议。谢谢