C++ program to find the length of a given string
gd.cpp
#include <iostream> #include <cstring> using namespace std; int main() { cout<<strlen("GoDarda")<<"\n"; }
Output
godarda@gd:~$ g++ gd.cpp
godarda@gd:~$ ./a.out 12 godarda@gd:~$
C++ program to find the length of a given string
gd.cpp
#include <iostream> #include <cstring> using namespace std; int main() { cout<<strlen("GoDarda\0")<<"\n"; }
Output
godarda@gd:~$ g++ gd.cpp
godarda@gd:~$ ./a.out 12 godarda@gd:~$
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