Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

I am unable to calculate exact size of string in C++ using strlen() or sizeof() function, Please help.

0 votes
asked Mar 3, 2021 by ABHISHEK KUMAR (120 points)

1 Answer

+1 vote
answered Mar 13, 2021 by xDELLx (10,520 points)
Are you using std::string ?? if yes use the string::size() method

Are you using raw strings , ie char array ., make sure it has extra 1 byte space for terminating null character , ie '\0'.strlen will work on char array with last byte having '\0' char.

Anyways the question is vague & needs more info for addressing issue.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...