I’m using a char[] of size 4 but when I use memcpy() function it stores 8 characters in it and also the character array length becomes 8. What is happing?
I don’t want to use malloc ok.
char strRoh[4]={'\0'};
and then
memcpy(strRoh,Dump+22,4);
Now tell me whats wrong with this
char strIP[]="hhhhhhhh";
char strRoh[4]={'\0'};
char strTheta[4]={'\0'};
char strTimeStamp[6]={'\0'};
char strNMDump[48]={'\0'};
is there any problem with decelerations cause when i change there order they strings also change there size now strroh is getting 10 chars
what a hell is going on with this
C strings are 0-terminated. This means that if you want to have a string of length
nin C, you needn+1chars for it:is not a string, because
hellohas space for 5chars, and it doesn’t end with0.is a string, and has 6 characters:
h,e,l,l,o,0.To be able to use string related functions in C, you need the terminating 0.
So, change your code to have:
Note that in C, when you do:
the compiler does the counting for you, and makes
helloan array of size 6 (one terminating 0):will print 6.