4 isn't the size of the string, because samplestring isn't a string. It's a char*, whose size is (on your platform) 4, divided by 1 (size of char) is, correctly, 4.
In C++, you'd use std::string and the length() method.
In C, you'd use strlen which takes as parameter a NULL-terminated char pointer.