Best practice to declare character array in C -


i have read data device 4 bytes long have declared array like

char data[4] = {0}; 

i parse per index , guarantee stop @ index 3.

data[0]..data[3]

in case there no room nul('\0').

i want know considered safe or should declare array as

char data[5] = {0}; 

this array not used in str* series of functions.

if data read string of 4 bytes or if greater 4 bytes , using char character array instead of string no need worry. otherwise have care '\0'.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -