CPP String Streams

C++ String Streams in Hindi – C++ in Hindi

C++

CPP String Streams in Hindi:- Input And Output Main Data Ke Flow Ka General Name Stream Hain. Isiliye C++ Main Streams Ko Iosteam Kaha Jata Hain. Lekin Ham Aaj C plus Plus String Stream in Hindi Ko Dekhe Ne Wale Hain |

What Is String Streams In Hindi – String Streams Belong Karta Hain Aapne String Object Ko Wo Bhi String Ke Sath And Iska Istemal C++ Main Read Karne Jaise Stream Cin Function Karta Hain |

C++ String Streams in Hindi

C Plus Plus String Streams Ke Bahut Se Methods Hain Niche Hamne Niche Ek Ek Karke Explain Kiya Or Inka Example Bhi Niche Hi Diya Gaya Hain|

  • clear(): Iska Istemal Stream Ko Clear Karne Ke Liye Kiya Jata Hain |
  • str(): Iska Istemal String Object Ko Get Or Set To get Karne Ke Liye Kiya Jata Hain To Content Present Hota Hain Stream Main |
  • operator << : Yah Add Karta Hain One String Ko Stringstream Main |
  • operator >> : Iska Istemal stringstream se object ko Read Karne Ke Liye Kiya Jata Hain |

String Streams Ke Two Examples Dekhte Hain.

1. Example:

Is Program Main Ham Words Ko Divide Karke Separate Stings Teyar Karenge |

#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
int main() {
   string str("Hello Welcome the Master Programing");
   string tmp; // A string to store the word on each iteration.
   stringstream str_strm(str);
   vector<string> words; // Create vector to hold our words
   while (str_strm >> tmp) {
      // Provide proper checks here for tmp like if empty
      // Also strip down symbols like !, ., ?, etc.
      // Finally push it.
      words.push_back(tmp);
   }
   for(int i = 0; i<words.size(); i++)
      cout << words[i] << endl;
}

Output:

Hello
Welcome
the
Master
Programing

2. Example

Is Program Main Ham Decimal Number Ko Hexadecimal Number Main Convert Karenge Using String Streams.

#include<iostream>
#include<sstream>
using namespace std;
main(){
   int decimal = 61;
   stringstream my_ss;
   my_ss << hex << decimal;
   string res = my_ss.str();
   cout << "The hexadecimal value of 61 is: " << res;
}

Output:

The hexadecimal value of 61 is: 3d

Also Read This Post:

Leave a Reply

Your email address will not be published. Required fields are marked *