Wat is the size of string?does string have specific size..??as like integer... Float.. Double.. Char...??

The size of a string will depend on the language used to store it.
Some languages use a terminator (like NULL or '$'), so the string will be the number of characters + the terminator.

Some languages use a size indicator byte (like Pascal) where the first byte is the size (up to 255) and the rest will be the actual string.

If it is a Unicode String, it will be as the link shows.

You will also need to look up string classes like CString in C++/MFC or System::String in C++/CLI std::string in C++ and String in java and ... and ...

Wat is a size of string in C++?does string has specific size?as like integer.. Float.. Char.. Double..

No set size. If you need to know, you'll have to find out at run-time.

You can find out the size of a string of characters yes

So it doesnt ve any specific size rite? Thank you.. :)

No does a string as any specific size,In C++?as like integer.. Here size of integer is 2bytes.. I am asking... Does string has specific like integer?

Yes! string doesn't have any specific size like int,float,etc.
For eg. char a[20]; Here string a is of size 20 bytes, char b[10]; Here string b is of size 10 bytes and so on.

There is two possible meanings for string:
1) pointer to char to memory location starting textual information, generally pointers would be same size all
2) the actual text pointed by the pointer to char, which could be simple name or novel. Typically space would be reserved dynamically by malloc family functions.

By the way this kind of technical C++ question would be better placed in C++ forum, even you have no code samples.

There are many tutorial on string in online. You can get idea fron there.

Do you want this.....

#include <iostream>
#include <string>
#include<conio.h>
using namespace std;

int main ()
{
  string str ("Test string");
  cout << "size: " << str.size() << "\n";
  cout << "length: " << str.length() << "\n";
  cout << "capacity: " << str.capacity() << "\n";
  cout << "max_size: " << str.max_size() << "\n";
  getch();
  return 0;
}

Look this out. here we get an easy way to enter string from the user, and then print out the strings length by using the string.length() function, here is only the code, you can get it detailed from:

http://www.programmingtunes.com/finding-length-of-a-string-in-c/

now the code is:

// Finding length of a string in C++

#include<iostream>
#include<string>
using namespace std;

int count(string);

int main()
{
    string str;
    cout << "Enter a string: ";
    getline(cin,str);
    cout << "\nString: " << str << endl;
    cout << count(str) << endl;

    return 0;

}

int count(string s){
    if(s == "")
      return 0;
    if(s.length() == 1)
      return 1;
    else
        return (s.length());

}
- See more at: http://www.programmingtunes.com/finding-length-of-a-string-in-c/
commented: Please stop resurrecting threads to spam your website. -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.