???C/C++??????????????
???????????? ???????[ 2013/12/24 13:14:55 ] ????????C C++ ???? ??????
?????????????????????????
?????????????????????????????????????????????????????????裺
??????1????“????”???????????????????н???????????????????
??????2???????Щ???????????ж??????????????????Щ???????Щ????????Щ???????????????????????????
??????3????????????????????????????????????????????????????????????к??????????????
????????????????????????????????????????п???????????????????????????Σ??????????????
???????磺?±??????Σ?????????????
?????? | Σ????? |
1 | strncpy??recv??lstrncat??strncat?? |
2 | fprintf??vsprintf??wscanf??lstrncpy |
3 | printf??sprintf??scanf??getchar??fget |
4 | strcat??strcpy??strlen |
??????????Щ???????????????????±??
???? | buffer | strncat | printf | sprintf | scanf | normal | strncpy |
???? | strcat??strcpy | strncat??lstrncat | printf??fprintf | sprintf??vsprintf | scanf??wscanf | strlen??recv??getchar??fget | strncpy??lstrncpy |
???????????????????崦???
??????1??????buffer??????????
?????????????????Σ???????????????????????????????????????????Σ????????????????????????????????????token??????????????????
??????????strcpy(dest??”abc”); //????????abc?????????
??????2??????strncat??????????
????????????????????????Σ?????????(???1)??????????????strncat(dest??src??len)???len????????????????????????????????????????????????????????????????????????????????????”sizeof(dest)”?????????Σ????檔?????????dest??????????????????sizeof(dest)??Σ?????????????????????????ЩΣ??????????ж????????????
??????????strncat(dest??src??sizeof(dest)-1);//Σ?????
??????3??????printf??????
??????????????printf??????????????????????????Σ?????????????????????????????Σ???????????????????vsnprintf?????????????????????
??????4??????scanf??????
??????scanf(format??addr)?????format????????????????????????????????format?漲??????s%????????й漲?????????????????????????????????ж????Σ??????????format?漲?????5s%?????????漲?????????????????Σ?????????????????ж????Σ???????Σ???
?????????scanf(“%s”??str);//Σ?????й漲??????????
????scanf(“%5s”??str);//str?????????5??Σ?????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11