Jumat, 24 Oktober 2014

String - character length and size - C++

Tags

Compiler online :
http://cpp.sh/

//Code to learn:
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
   char a[5]="abc";
    cout<<sizeof(a);
    cout<<endl;

    string s;
    s=a;
    cout<<s.length();
    cout<<endl;
    cout<<s.size();
    cout<<endl;
//other output type
    cout<<"String = "<<s.size()<<endl;
    cout<<"Size of string :"<<s.size()<<endl;
    cout<<"Size of string :"<<s.length();
    return 0;
}


EmoticonEmoticon