VOOZH about

URL: https://www.geeksforgeeks.org/cpp/convert-string-to-size_t-in-cpp/

⇱ Convert String to size_t in C++ - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Convert String to size_t in C++

Last Updated : 23 Jul, 2025

To convert String to size_t  in C++ we will use stringstream, It associates a string object with a stream allowing you to read from the string as if it were a stream (like cin). We must include the stream header file in order to use stringstream. When parsing input, the stringstream class comes in quite handy.

Syntax:

std :: stringstream stream(string_name)

Example: 

Output:

Hello Geek
GeeksforGeeks

Example: 

Output: 

246810
Comment