Results 1 to 1 of 1

Why we use string library in C++?

This is a discussion on Why we use string library in C++? within the C++ forums, part of the Courses category; Suddenly I missed adding string library in my program and it was still working fine why? Code: <br></span><pre style="margin-top: 0px; ...

  1. #1
    iTT Student Khanlion's Avatar
    Join Date
    Oct 2015
    Location
    Khushab
    Age
    26
    Posts
    3

    Question Why we use string library in C++?

    Suddenly I missed adding string library in my program and it was still working fine why?

    Code:
    <br></span><pre style="margin-top: 0px; margin-bottom: 0px; color: rgb(0, 0, 0); font-size: 12px;"><code><dfn style="font-style: normal; color: rgb(80, 0, 112);">#include &lt;iostream&gt;</dfn>
    <dfn style="font-style: normal; color: rgb(80, 0, 112);">#include &lt;string&gt;</dfn>
    <var style="font-style: normal; color: rgb(0, 0, 176);">using</var> <var style="font-style: normal; color: rgb(0, 0, 176);">namespace</var> std;
    <var style="font-style: normal; color: rgb(0, 0, 176);">int</var> main()
    {
     string day = <kbd style="color: rgb(96, 0, 48);">"Monday"</kbd>;
     
     cout &lt;&lt; day &lt;&lt; <kbd style="color: rgb(96, 0, 48);">" Go to school\n"</kbd>;
     
     <var style="font-style: normal; color: rgb(0, 0, 176);">return</var> 0;
    }</code></pre><span style="color: rgb(0, 0, 0); font-family: verdana, arial, helvetica, sans-serif; font-size: 12px;">
    and also working without string library:-

    Code:
    <br></span><pre style="margin-top: 0px; margin-bottom: 0px; color: rgb(0, 0, 0); font-size: 12px;"><code><dfn style="font-style: normal; color: rgb(80, 0, 112);">#include &lt;iostream&gt;</dfn>
    <var style="font-style: normal; color: rgb(0, 0, 176);">using</var> <var style="font-style: normal; color: rgb(0, 0, 176);">namespace</var> std;
    <var style="font-style: normal; color: rgb(0, 0, 176);">int</var> main()
    {
     string day = <kbd style="color: rgb(96, 0, 48);">"Monday"</kbd>;
     
     cout &lt;&lt; day &lt;&lt; <kbd style="color: rgb(96, 0, 48);">" Go to school\n"</kbd>;
     
     <var style="font-style: normal; color: rgb(0, 0, 176);">return</var> 0;
    }</code></pre><span style="color: rgb(0, 0, 0); font-family: verdana, arial, helvetica, sans-serif; font-size: 12px;">
    Last edited by Charlie; 2nd September 2016 at 11:09 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •