C++ program to find the length of a given string
kw.cpp
#include <iostream> #include <cstring> using namespace std; int main() { cout<<strlen("KodingWindow")<<"\n"; }
Output
kodingwindow@kw:~$ g++ kw.cpp
kodingwindow@kw:~$ ./a.out 12 kodingwindow@kw:~$
C++ program to find the length of a given string
kw.cpp
#include <iostream> #include <cstring> using namespace std; int main() { cout<<strlen("KodingWindow\0")<<"\n"; }
Output
kodingwindow@kw:~$ g++ kw.cpp
kodingwindow@kw:~$ ./a.out 12 kodingwindow@kw:~$
Comments and Reactions
What Next?
C++ program to reverse a given string using loops
C++ program to reverse a given string using predefined methods
C++ program to reverse a given string using recursion
Advertisement