This is an C assignment for school but I'm running into to something strange that I don't know if it is normal or not.
I have to take command line arguments and an example of one is
-ia.b
so within my program I dynamically allocate memory with malloc
char *fileName = NULL;
fileName = malloc(strlen(argv[i]) * sizeof(char));
//error testing etc
strcpy(fileName, argv[i]);
Works fine, but I look into memory via visual studio debugger this is what become allocated at the memory location which to me is more room then needed:
0x01608b98 "ÍÍÍÍÍýýýýB`\x1˜?`\x1\xf1¼O{º"
if I cast malloc such as so fileName = (char*)malloc(strlen(argv[i]) * sizeof(char));
I get this allocated in memory:
0x009d8d38 "ÍÍÍÍÍýýýýB"
Considering that my argument is 5 bytes, is malloc allocating more memory then it should or am I just doing this incorrectly?