unable to use safe string function in C | Sololearn: Learn to code for FREE!

+4

unable to use safe string function in C

C11 introduces new function to eradicate buffer overflow while using string in C, --> strnlen_s, strncmpy_s etc where introduced, according to my research I can use this function using #define __STDC_WANT_LIB_EXT1__ 1, the problem now is that it's not working https://code.sololearn.com/cvNapT5f0CFV/?ref=app

4/3/2019 6:25:57 PM

✳AsterisK✳

13 Answers

New Answer

+3

You can see a reason for the problem here : https://stackoverflow.com/questions/47867130/stdc-lib-ext1-availability-in-gcc-and-clang

+5

~ swim ~ its not working on a compiler

+4

~ swim ~ according to the information TheWhiteCat💡 provided for me, it was not full accepted into the gnu11

+4

version 4.2.1 on my mobile 4.9.2 on my PC

+4

thanks ~ swim ~ 👍👍👍

+3

You can find useful info in this discussion: https://stackoverflow.com/questions/15610053/correct-printf-format-specifier-for-size-t-zu-or-iu?lq=1. According to the discussion this prefix "z" is not supported by Microsoft. You can use "I". You can see it in the code. https://code.sololearn.com/cvEyE4Wac4m1/?ref=app

+3

TheWhiteCat💡 thanks I will check the link out now, but the last printf is not outputting anything, which is the part I really need edited: thanks, the thread do not answer my question

+3

*AsterisK* shouldn't the last ifdef be #ifdef __STDC_WANT_LIB_EXT1__ instead of #ifdef __STDC_LIB_EXT1__ I tried on rextester and it works https://rextester.com/QST41074

+2

thanks alot TheWhiteCat💡 , now I need to get my hope out of that, maybe create my own safe functions, 😉😉😉😉

+2

*AsterisK* On rextester the compiler version is //Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64

+2

*AsterisK* Yes it doesn't work on gnu compilers, that's why i tried on rextester with microsoft compiler, as far as i know it was microsoft specific, didn't knew it was introduced in C11.

+1

*AsterisK* , you are welcome 😉

+1

*AsterisK* what is your compiler version?