Have I achieved a null- terminated C-string through the code?

I get compiler warning

A warning, not an error

warning: unused variable 'val' [-Wunused-variable]

What it says is quite true. You never use the val variable in your code