According to C99 standard all of the 10 elements of x are set to zero. Unless you are using ancient Solaris compilers or something.... try it with this junk code in debug mode:
edit: see para 21 in section 6.7.8 of C99 standards.
void foo(void)
{
int b[3]={0};
char c[4]={0x0};
/* this point */
}
int main()
{
foo();
return 0;
}
If you are going to pass numerics as an int then in the example the number part of the logical name will go from 00001 to 1 as leading zeros will be removed from an int. Is that what you want or do you want to pass a numerical string --> 00001 ??
I have very lightly changed jim mcnamara's code...hope he is with that.
As the model and num variables are going to be used in other functions make them global and the update_new_logical_name() function need not return anything.
#include <string.h>
char part_one[3];
int num;
void update_new_logical_name(char *src)
{
if(strlen(src)>=3)
memcpy(part_one, src, 3);
if(strlen(src)>=8)
num = atoi(src+3);
printf ("model = %s num = %s\n, part_one, num);
}
Post the code that you are using...since the one that you are using isn't giving the desired output. Given the string jkl00001 the code in my last post works correctly. It will be incorrect only if the input string changed. Is that the case?