I am at a total loss with this one. I can't figure out why this isn't working. Simple character array with a NULL terminator - except that when I output it, it doesn't terminate!
int file_create(const char *path) {
//trying to trap situations where the path starts with /.goutputstream
char path_left_15[16];
strncpy(path_left_15, path, 15);
printf("%d\n", strlen("/.goutputstream")+1);
path_left_15[strlen("/.goutputstream")+1] = '\0';
printf("%d\n", strlen(path_left_15));
printf("path_left_15: %s\n", path_left_15);
//continue on...
}
This is my output:
> 16
> 16
>/.goutputstream\B7<random memory stuff>
I can't figure out why this isn't terminating correctly. I've tried making the array longer, but I get the same result every time. I'm losing my mind!
Anyone see it? Thanks.