开发者

String reading in c

开发者 https://www.devze.com 2022-12-23 01:50 出处:网络
I have little doubt about string reading in C. string reading functions like gets, scanf, read, fscanf , fgets...

I have little doubt about string reading in C.

string reading functions like gets, scanf, read, fscanf , fgets...

which C function can do a secure or safe string reading from any file?

Or

Which C开发者_StackOverflow社区 function can be reliable to read a string in a file ?


An input function will be secure/safe(not allow buffer overflow) if it takes the length of the buffer as an arguments so that the function does not read more char than the buffer can hold.

Of the function you've listed fgets() and read() take the buffer length as argument and can be considered safe.


Seems like you are simply asking how to read in a file. Google was helpful for me:

http://www.cprogramming.com/tutorial/cfileio.html

http://msdn.microsoft.com/en-us/library/aa365467%28VS.85%29.aspx

Read around or expand your question so we can answer you better.

0

精彩评论

暂无评论...
验证码 换一张
取 消