2017-04-07 1 views
0

다음과 같이 char *를 반복합니다. 그러나 표시된 줄에서 오류가 발생합니다. C2446 '! ='char *에서 int 로의 변환이 없습니다. char * error 반복 없음 char *에서 int 로의 변환

 int errorLineNumber = 0; 
     char* json; //this is a long json with multiple \n's in it. 
     int offset = errorOffset; 
     char* p = json + offset; 
     while (*p-- != '\n' && offset--); //check that this gives offset on that error line and not char position of end of last line before error 
     errorLineOffset = errorOffset - offset; //get offset on error line only 

     //count lines to json error 
     long errorLineNumber = 0; 
     while (*p!= json) //this is error line 
      errorLineNumber += *p-- == '\n'; 

나는 conversion const char to tchar 보았다,하지만 조금 다른, 그리고 나 또한 내가 뭔가를 누락하지 않는 한 나는 여전히 같은 문제라고 생각하지 않습니다 conversion const char to int, 바라 보았다.

내가 누락 된 것이 누군가에게 좋은 아이디어라면 좋을 것입니다. 감사!

while (*p != json) 

라인

에서

+1

관련된 변수의 유형을 표시하십시오. –

+0

VS2015에서 잘 작동 – alexeykuzmin0

+1

(p! = json) 동안을 의미하지 않습니까? – jwimberley

답변

1

당신은, 포인터를해야 위의 코드에 따라, 나는 그것이 * 유형`const를 문자로 가정하는 json에 입력 char의 인 *p 비교합니다. 해야 할 일

while (p != json) ... 
관련 문제