【发布时间】:2021-09-10 12:06:48
【问题描述】:
我有以下以错误代码结尾的字符串int。比如0、511、512、513等
我想得到那个号码。
字符串是这样的:
+QIND: "FOTA","END",0
0 是错误代码。
这是我的试验:
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
// your code goes here
char tempdata[40] = "FOTA\",\"END\",0";
char* res = strstr(tempdata, "FOTA\",\"END\"");
if(res != NULL)
{
int percentage = atoi(res + strlen(tempdata) + 1);
cout << percentage << endl;
}
return 0;
}
【问题讨论】:
-
- 这对你有什么影响?