For Loop

This is a piece of code from a book that wont compile. It report's index was not declared in this scope, And it look's like index will alway's be 0(zero).
I added the s = some string line to give something to work with.

1
2
3
4
5
6
7
8
9
#include <iostream>
#include <string>
#include <cctype>

int main()
{
    std::string s = ("some string");
    for (decltype(s.size()) index = 0; index != s.size() && !isspace(s[index]); ++index); s[index] = toupper (s[index]);
}
Last edited on
Remove the semicolon after the closing bracket of the loop.
Thank's maeriden.
Topic archived. No new replies allowed.