我正在尝试像这样使用 strstr 函数:
const char * pInicio = strstr(origem, chave);
if (pInicio != NULL) ...
与预期相反,当我进行“if”测试时,编译器会抛出访问位置冲突异常。每次我尝试从字符串中获取一些不存在的关键字时都会发生这种情况。
调用栈是:
ntdll.dll!779315de()
[Os quadros abaixo podem estar incorretos e/ou ausentes, nenhum símbolo foi carregado para ntdll.dll]
ntdll.dll!779315de()
ntdll.dll!7792014e()
> msvcr100d.dll!_output_l(_iobuf * stream, const char * format, localeinfo_struct * plocinfo, char * argptr) Linha 2361 + 0xa bytes C++
cccccccc()
输出是:
Exceção de primeira chance em 0x0f8620a7 (msvcr100d.dll) no TestesApp.exe: 0xC0000005: Violação de acesso ao ler o local 0x00000001.
Exceção sem-tratamento em 0x779315de no TestesApp.exe: 0xC0000005: Violação de acesso ao ler o local 0x00000001.
在异常之前,变量值是:
- 查韦:0x00196f64“$ GNGSA”类型:字符*
- 原点:0x00196840 "$GPRMC,000651.082,V,,,,,,,191210,,,N*4F $GPGGA,000652.091,,,,,0,00,,,M,0.0,M,,0000*5F $ GPGSA,A,1,,,,,,,,,,,,,,,*1E" 类型:const char *
- pInicio:0x00000000 无效>类型:const char *
链接器命令行是:
/OUT:"C:\Users\Leandro\documents\visual studio 2010\Projects\TestesApp\Debug\TestesApp.exe" /INCREMENTAL /NOLOGO "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Debug\TestesApp.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Leandro\documents\visual studio 2010\Projects\TestesApp\Debug\TestesApp.pdb" /SUBSYSTEM:CONSOLE /PGD:"C:\Users\Leandro\documents\visual studio 2010\Projects\TestesApp\Debug\TestesApp.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE
c/c++ 命令行也是
/ZI /nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Debug\TestesApp.pch" /Fa"Debug\" /Fo"Debug\" /Fd"Debug\vc100.pdb" /Gd /analyze- /errorReport:queue
在此之后,我尝试测试指针是否为空。这是我现在的问题,如何解决?
此致!