strrchr() - return 0 when you search '\0' char
:sample test code
void test(void) { char * ptr; char testString[8] = "hello"; ptr = strrchr( testString, '\0' ); if(ptr) { *(ptr - 1) = '~'; } printf("%s\n",testString); }
Expected output : hell~ (Tested and works on standard libraries on windows and Linux)
Actual output:hello. (On KEIL, Not ok)
IDE-Version:µVision V5.28.0.0Copyright (C) 2019 ARM Ltd and ARM Germany GmbH. All rights reserved.
Tool Version Numbers:Toolchain: MDK Professional 5.28 (Flex) Version: 5.28.0.0Toolchain Path: C:\Keil_MDK528a\ARM\ARMCC\BinC Compiler: Armcc.exe V5.06 update 6 (build 750)Assembler: Armasm.exe V5.06 update 6 (build 750)Linker/Locator: ArmLink.exe V5.06 update 6 (build 750)Library Manager: ArmAr.exe V5.06 update 6 (build 750)Hex Converter: FromElf.exe V5.06 update 6 (build 750)CPU DLL: SARMCM3.DLL V5.28.0.0Dialog DLL: TCM.DLL V1.36.2.0Target DLL: STLink\ST-LINKIII-KEIL_SWO.dll V3.0.6.0Dialog DLL: TCM.DLL V1.36.2.0