#include <iostream>
#include <string>
#include <ctype.h>
usingnamespace std;
string capital(string name)
{
for (int i = 0; i < name.length(); i++)
{
name[i] = toupper(name[i]);
}
return name;
}
int main()
{
string name = "robbie";
cout << capital(name) << endl;
}
So far I got that code up while trying to make robbie into ROBBIE my problem is not being able to loop correctly to help toupper do its job any help as to what I need to fix
stupid on my part but should have been easily overlooked by you imo.
I see. I genuinely thought this was your code and that was the mistake you made. I suggest that you copy and paste your code in future so that the code you show us is the code that doesn't work.
i > name.length();
This will be false from the start, so the loop will never be executed. Try
i < name.length();
I thought about ignoring this error because it's clearly a typo, as you suggested, but thought maybe I should point it out anyway.
heh thanks for that one I clearly overlooked that one entirely in my code. I had though I wrote the array wrong but sadly it was just the < that was wrong once again I feel stupid after this thanks for the help and I couldn't really copy paste this since there is more to the program than the small section showed the original is a jumbled mess but I appreciate the help even though it was a small thing