I wanna know how 2 return string by using function for example if we want to check the lenght of string we use cout<<strlen("c") but how to use this by fuction
hurricane123
-11
Newbie Poster
Recommended Answers
Jump to Post#include<iostream> #include<string.h> using namespace std; int main() { char x[] = {"hello"}; cout<<strlen(x); return 0; }
Jump to PostUse C++ string, they are better, and more stable.
#include <string> #include <iostream> int main (void) { std::string strFirst; std::cin >> strFirst; std::cout << strFirst.size (); return 0; }
For more information about strings:
www.cplusplus.com/reference/string/string/
All 5 Replies
Software guy
6
Junior Poster
n.utiu
0
Light Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
n.utiu
0
Light Poster
webs1987
0
Newbie Poster
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.