iterator string

This is a discussion on iterator string within the C++ Programming forums, part of the General Programming Boards category; Code: 59: string::iterator it = line.begin(); 60: int j = 0; 61: for ( ; it < line.end(); it++) 62: ...

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    10

    iterator string

    Code:
    59:	string::iterator it = line.begin();
    60:	int j = 0;
    61:  	for ( ; it < line.end(); it++)
    62:  		for ( ; j < width_; j++ )
    63:    	maze_[i][j] = *it;
    compiler says:
    61: error: ‘it’ was not declared in this scope

    I say:
    "WTF?"

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    Provide the smallest possible compilable code that demonstrates the problem?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    1,197
    From those lines of codes pretty much the only cause i can find for that error is that you forgot to use the std namespace (ie. need to use std::string::iterator).

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21