I get the following error:
2 smartcard.c: In member function ‘virtual bool cSmartCards::ParseLine(const char*, bool)’:
3 smartcard.c:1187:25: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
4 char *r=index(line,':');
5 ^
The code is:
1184
1185 bool cSmartCards::ParseLine(const char *line, bool fromCache)
1186 {
1187 char *r=index(line,':');
1188 if(!r) return false;
I included "string.h"
How can I rewrite line 1187?
index() can be found in string.h.
答案 0 :(得分:5)
Either or both of the following:
index
returns const char*
, not a char*
. So, make r
a const char*
, not a char*
.
The function index
is written to expect a char*
, not a const char*
. I cannot safely suggest a fix for this without knowing what index
is and does.
答案 1 :(得分:0)
答案如下:
Function index is found in string.h.
Change line 1187 to: const char *r=index(line,':');