Thread: iterator string

  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をこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    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,218
    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