Answers for "strlen in c++"

C++
4

strlen in cpp

#include <cstring>
#include <cstring>

using namespace std;

int main(void) {
  char stringName[] = "This contains the content of your string";
  int stringLength = strlen(stringName);
  cout << "String: " << stringName << endl << "Length of String: " << stringLength << endl;
  
  return 0;
}
Posted by: Guest on February-11-2021
2

c++ length of char*

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

using namespace std;

int main()
{
    char *str = "ABC";
    cout << strlen(str) << endl;
    return 0;
}
Posted by: Guest on August-01-2020
0

strlen in cpp

#include <cstring>
#include <iostream>

using namespace std;

int main()
{
    char str1[] = "This a string";
    
    int len1 = strlen(str1);

    cout << "Length of str1 = " << len1 << endl;

    return 0;
}
Posted by: Guest on October-20-2020
0

strlen in c++

#include <cstring>
strlen(str);
Posted by: Guest on June-05-2021
0

use of strlen in C++

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

int main() {

  // initialize C-string
  char song[] = "We Will Rock You!";

  // print the length of the song string
  cout << strlen(song);

  return 0;
}

// Output: 17
Posted by: Guest on September-02-2021
0

strlen in C++

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

int main() {
  char str1[] = "This a string";
  char str2[] = "This is another string";

  // find lengths of str1 and str2
  // size_t return value converted to int    
  int len1 = strlen(str1);
  int len2 = strlen(str2);

  cout << "Length of str1 = " << len1 << endl;
  cout << "Length of str2 = " << len2 << endl;

  if (len1 > len2)
    cout << "str1 is longer than str2";
  else if (len1 < len2)
    cout << "str2 is longer than str1";
  else
    cout << "str1 and str2 are of equal length";

  return 0;
}
Posted by: Guest on September-02-2021

Browse Popular Code Answers by Language