I'm working on this string function but i cant get it to work. I almost have it but i'm getting these errors....
1 error C2065: 's' : undeclared identifier
2 error C2228: left of '.length' must have class/struct/union
3 warning C4390: ';' : empty controlled statement found; is this the intent?
You didn't return a value in your NumDouble function. Unless the function is void, it has to return a value. I'm guessing you will need a counter after the condition on line 10 to keep track of the number of doubles. Your function will not do what you want even after fixing what I just mentioned because of line 6; why do you need another string in the function when you are getting a string as your parameter?
this is a problem i have for the class and i cant figure it out. this is what the question says....
" Write a function called NumDouble that takes a string S as an argument
and returns the number of times there is a double-letter inside it.
For example if S=“happy” then the function returns 1.
If S=”balloon” or S=”Zaxxxon” the function returns 2.
If S=”Lollapallooza” the function returns 3… etc "
I'm a beginner and I'm having trouble with this and the professor doesn't know how to explain this properly.
Ok you are pretty much 80% done this function, you just have to:
1: create a new int varaible inside your function above the for-loop
2: Set this value to 0
3: Remove string s line 6
4: Remove the semicolon at line 10 and instead increment the variable you created
5: Return the variable you created by placing return nameofvaluehere; below the closing bracket of the for-loop
The reason for creating a new variable is so that you can count the number of times your if-statement (line 10) evaluates to true
The reason for not having a string in your function is so that you use the string S in your parameter
Reason for returning a value in your function is because that is the purpose of this project
Your for loop has no statement(s), it just checks to see if x == y and then doesn't do anything. It is incomplete. That is why you are getting an error saying it does not return a value. The function must return an integer value or be declared as void.
You didn't take out string s, it is still there on line 8
Remove the semicolon after your for-loop on line 9 and after your if-statements on line 11
You declared variable nd 2wice line 6 and line 9
You are still not incrementing the value you set to zero.
Dude, get a piece of paper, write down the instructions the way you understand them and type it here. It seems you are a little scatter brained atm and you gotta focus on the task at hand