Array access violation reading location



  • Hi
    Im new to this forum and wanna post something, but I dont really understand how the

    and
    

    tags work. I saw your "please set the code in codetags" message but I dont get how...

    (class cField):

    class cField {
    public:
    	cField() {}
    	cField(int x_, int y_) {
    		for (int y = 0; y < 10; y++)
    		{
    			for (int x = 0; x < 10; x++)
    			{
    				if (x_ == x && y_ == y)
    				{
    					cout << "O" << "  ";
    				}
    				else {
    					cout << "#" << "  ";
    				}
    			}
    
    			cout << endl << endl;
    		}
    	}
    
    	void write(char toWrite, int x_, int y_) {
    		field[y_][x_] = toWrite;
    	}
    
    	char read(int x_, int y_) {
    		return field[y_][x_];
    	}
    
    private:
    	char field[10][10];
    
    };
    


  • Easy: Don't deactivate BBCode next time, then the [cpp] tags will magically start working.

    Any other questions? Or do you seriously expect us to derive some kind of question from the title and some code that you posted? That would be so cute...



  • Your code isn't wrong and doesn't lead to an access violation. The best way to solve this is to use a debugger, which will tell you where the access violation is thrown. It also enables you to inspect variables to locate the cause.



  • Welcher dümmliche Dämon reitet Euch eigentlich, daß Ihr immer auf englisch antworten müsst, wenn jemand eine englische Frage postet?
    Das sind doch zu 99% bloß Sprachtrolle; die anderen 1% können Eure Antworten auch durch den google-Übersetzer schicken.
    Der 4-Gewinnt-Basti hat sich nichtmal umgeloggt. 😉



  • Ei der daus da wird doch der Hund in der Pfanne verrückt 😡



  • volkard halt einfach deine dümmliche Fresse wenn du nix zu sagen hast.


Log in to reply