Posted: Wed Jan 23, 2008 7:17 pm Post subject: Check this
I cant seem to find the problem with this. What this program does, is trys to find the length of the specified word, and print it. In this case im getting an error. Any Clues?
1. Why are u using void main? use int main.
2. C++ is case sensitive, you defined "Length" then u called on "length"
3. there is a header called "string" and it helps to use it cuz its got its own string length function built in, yayy
Code:
#include <iostream>
#include <string>
int stringLength(std::string str)
{
int strLength = str.length();
return strLength;
}
int main()
{
int strLen = stringLength("Dan");
std::cout << strLen;
std::cin.sync();
std::cin.ignore();
return 0;
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum