Need a project done?

C++ Programming Developer

Search This Blog

How to tell Number of Characters in String in C++?

//How to tell Number of Characters in String?

#include <iostream.h>
#include <cstring>

void main()
{
char a[] = "Bye";
cout << "Number of Characters in array a[]: "<< strlen(a) << endl;
}



4 comments:

  1. #include
    using namespace std;


    int main()
    {
    char a[15] = "string of mine";

    cout<<"no of characters in array a[] are :"<<strlen(a)<<endl;


    return 0;
    }


    It is working without including cstring

    ReplyDelete
    Replies
    1. When u include , You will have to include

      In case you include , then no need to include

      Delete
  2. when we include #include than we don't need to include cstring this is what you want to say?????

    ReplyDelete
    Replies
    1. Sorry, the comment could not be posted, as I wrote.
      Include iostream => no need of cstring
      Include iostream.h => Must include cstring.

      Delete

"Don't let anyone ever make you feel like you don't deserve what you want."