Strings in C++ in Hindi

C++ in Hindi – Strings in C++ in Hindi

C++

Strings in C++ in Hindi :- String Characters of Callaction Hoti hai | Aashan Word Me Kahe to jab words ko ek sath me likha jata hai to string banti hai |

String = "Hello Friends"

String C++ in Hindi

  • Introduction to C++ strings in Hindi
  • C++ string class in Hindi 
  • Creating C++ string objects in Hindi
  • String in C++ with Examples in hindi

C++ me kasi word ko ya character ko store karne ke liye aap char Data Type ka variable bana sakte hai | Lekin string ko store karne ke liye C++ me koi bhi built in data type Nhi Hota Hai |

C++ String Class In Hindi

String ko store karne ke liye aap String class ka istemal kar sakte hai | String Class me 3 constructors available hai | pahla constructor empty string object banane ke liye hai |

pahla constructor empty string object banane ke liye hai |

Example:

String(); 

Aap Upper Dekh Sakte hai Hamne String ka Pahla Constructor Hamne Empty Create kiya hai |

Aap Dusra Constructor Argument ke rup mei pass ki gayi string se string object bana sakte hai |

Example:

String(char *strchar); 

Aap Upper Diye Gaye Output ko dekh Sakte hai |

Aap 3 Constructor argument ke rup mei ek string object hi leta hai or uski string se naye object ko create karta hai |

Example:


String(string &strchar); 

Creating String Objects in Hindi

String Class ke object aap kisi bhi normal class ke objects ki tarah hi bana sakte hai | Lekin String Class me 3 Constructors defined hai | isliye aap string objets bhi 3 tarah se create kar sakte hai isko ham example ke sath samnajh te hai |

Example:


#include <iostream>
#include <string.h>

int main()
{
    // yha par constructor ko call karenge with char argument ke sath


    string st1(“Welcome Friends”);  

    // yha par ham normal constructor ko call karenge or string ko empty create karenge


    string st2;  
 

    // yha par ham constructor ko call kar rhe hai with char argument ke sath 


    st2 = st1; 
    cout<<st1;  
    cout<<st2; 
   
    return 0;
} 

Output:

Welcome Friends
Welcome Friends

Aap Upper Diye Gye Output ko dekh Sakt hai hamne keval string variable crate karke or fir string ko dusri variable me assign karke dono ko print kara diya hai |

Getline() Funtion in String

Agar Aap User Se String Inpur kavana chahte hai to aap getline method ka istemal kar sakte hai is method me aap 2 arguments pass karte hai | pahla argument cin hota hai jo keyboard ke liye default input ke liye hota hai | or dusra argument string object hota hai jiske liye aapne input karaya hai | Ise Ham Example ke sath samnajh te hai |

Example:

#include <iostream>
#include <string.h>

int main()
{
 string st1;     // string variable

 getline(cin,st1)  // get user input line 

 cout<<st1; 
   
    return 0;
} 

Output:

Hello   // user input
Hello   // user output

Aap Upper Dekh Sakte hai or program ko samnjh sakte hai |

C++ Functions of String In Hindi

C++ String me bahut se function hai me aapko In functions ke bare me bata rha hu jo ham string ke sath istemal kar sakte hai |

Lets See One By One

begin() :- Ye ek iterator type ka function hai| ye function call kiye jane par string ki starting (beginning) ka pointer return karta hai |

end() :- Ye bhi ek iterator type ka function hai | ye function call hone parstring ka end (ending) pointer return karta hai |

append() :- Yadi aap kisi ek string ke last me koi dusri string ko add ya jodna chahte hai to aap append() function ka istemal kar sakte hai |

Example:

strng1.append(strng2); 

At() :- Yadi aap string me particular location se kisi character ko lena chahte hai to aap uske liye at() function ka istemal kar sakte hai |

Example:

strng1.at(3)

compare() :- Agar aap two string ko campare karna chahte hai to aap compare() function ka istemal kar sakte hai |

Example:

strng1.compare(strng2);

empty() :- Agar Aap string ko pta karna chahte hai ki sting empty() hai ya Nhi to aap empty() function call karke pta kar sakte hai |

Example:

strng1.empty();

erase() :- Agar aap string me se kisi bhi character ko erase ya delete karna chahte hai to aap erase() function ka istemal kar sakte hai |

Example:

 strng1.erase(3,2);  

Find() :- Agar Aap String me koi bhi sub-string find karna chahte hai to iske liye find() method ka istemal kar sakte hai |

Example:

strng1.find(“sub_string”); 

Length() :- Agar Aap String ki length ka pta karna chahte hai to aap length() function ka istemal kar sakte hai |

Example:

length(strng1);

swap() :- Agar aap 2 objects ki string ko aapas me swap karna chahte hai to isliye aap swap() function ka istemal kar sakte hai |

Example:

strng1.swap(strng2) 

Also Read This Post :

Strings in Cpp in Hindi

Strings in C++ in Hindi

Dosto mujhe ummed hai ki aap Strings in C++ in Hindi  ko acchi tarah se samanj gye honge agar aap ko ye post acchi lage to mere is website ko jarur follow kre or ha agar aap video bhi dekhna chahte hai to aap mere channel ko bhi subscribe kar sakte hai. channel ka link aapko home page par mil jayega |

Leave a Reply

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