hi guyz i need ur help, i have this game with 5 files: 2 header files 3 cpp source files, we i compile it i get this error:

error C2065: 'i' : undeclared identifier

plz check the attachment, the files are there


appreciate the answer :).

Attachments

>error C2065: 'i' : undeclared identifier

The specified identifier "i" was not declared in your program. A variable’s type must be specified in a declaration before it can be used.

did u check the attachment, plz tell me where exactly i should declare the identifier "i"

thanx for answer

Why is declaring i a problem for you?

I mean, you've managed to get to "2 header files 3 cpp source files".
Unless it isn't actually your code at all....

Comments
True. It isn't his/her code.
you should help members not crtitisize them

it's strange 1 week i'm searching for the error i declared the variable, why it gives error, somebody plz help

tell me where exactly i should declare the identifier "i"

If you look at the compiler error message, it includes the file and also the line number where the error occurs, for example, given an error message like:

foobar.cpp(10) : error C2065: 'i' : undeclared identifier

you should open foobar.cpp and look at the line 10. Furthermore, since you seem to be using Visual Studio, you can double-click on the error message (shown in the Output window) and the IDE will navigate to the correct file/line.

This is basic coding skill.
If we well you, you're not going to figure out how to fix your own mess in future.

> it's strange 1 week i'm searching for the error
Pathetic.

Edited 6 Years Ago by Salem: n/a

If you look at the compiler error message, it includes the file and also the line number where the error occurs, for example, given an error message like:

foobar.cpp(10) : error C2065: 'i' : undeclared identifier

you should open foobar.cpp and look at the line 10. Furthermore, since you seem to be using Visual Studio, you can double-click on the error message (shown in the Output window) and the IDE will navigate to the correct file/line.

well, it point to the for loop and this is how i wrote the for lopo:
for (i=1;i<=3;i++) , where the error can somebody tell me???

Edited 6 Years Ago by phpangel: n/a

As I thought

* Date:   [B]Feb 09, 06 [/B]                 File Name: Lab2.cpp
* Program Description:
*    A simple tictactoe game.

Not your code, you just grabbed it off the net, hoping it would fix your homework assignment, and now you want us to FIX IT FOR YOU without you spending any more effort.

Comments
I've always liked your posts because they are built upon strong facts :)

This is basic coding skill.
If we well you, you're not going to figure out how to fix your own mess in future.

> it's strange 1 week i'm searching for the error
Pathetic.

why u r criticizing other members, if u r not ready to help and guide others, simply say it i cant HELP, otherwise dnt criticize members and make their work harder!

Comments
Ever noticed that your post can actually be applied to yourself as well :P
No! You must have to show your code.

>why it gives error?

Read post #2

>somebody plz help

Your request for help smells like you're saying "please do it for me".

Take a look at TicTacToe.cpp

...
int TicTacToe::GetStatus()
{
   ...
  for ([missed]int [/missed]i=1;i<=3;i++){
    for (int j=1;j<=3;j++){
 	if (t[j][i]=='X')
          count++;
   }
 ....
 for ([missed]int [/missed]i=1;i<=3;i++){
   for (int j=1;j<=3;j++){
      if (t[j][i]=='O')
	count++;
   }
   ...
}
...

Edited 6 Years Ago by __avd: n/a

Comments
Nice try, but I rather suspect that [missed] will turn into a "not an array" error message for the OP ;)

As I thought

* Date:   [B]Feb 09, 06 [/B]                 File Name: Lab2.cpp
* Program Description:
*    A simple tictactoe game.

Not your code, you just grabbed it off the net, hoping it would fix your homework assignment, and now you want us to FIX IT FOR YOU without you spending any more effort.

this is my work on lab session, i ddnt grab it from any website, if i want tic tic toe game, there thousand of codes in internet that are running without errors. why i would come here and bother u to fix such an error!

what's missed in my "for" loop, this is how i write it:
for (int i = 1; i <= 10; i++)

can u specify?

what's missed in my "for" loop, this is how i write it:
for (int i = 1; i <= 10; i++)

can u specify?

You are looking at the wrong line there. You have several for loops, of which some are correct and some are not. The link that Salem posted explains the error quite well.

You are looking at the wrong line there. You have several for loops, of which some are correct and some are not. The link that Salem posted explains the error quite well.

i cant figure out wherez the error or at which line exactly, can u guyz specify which line/s?

appreciate the answer

i cant figure out wherez the error or at which line exactly, can u guyz specify which line/s?

Sigh, surely you must understand by now, that it's practically impossible to believe that You wrote that code yourself, right?.

Anyway, perhaps read this

Post #12 is as close to an answer on a plate as you're likely to get.

If you can't see the answer from there, just give up at being a C++ programmer.

> why i would come here and bother u to fix such an error!
Because that code WAS CORRECT with an OLD C++ compiler, but it is broken for a NEW C++ compiler. The link I posted (assuming that you haven't read it) explains that (and the reason why).

> this is my work on lab session, i ddnt grab it from any website
> Date: Feb 09, 06
So you're 4 YEARS in the past are you?
Here's a tip for the up-coming financial disaster - sell property, buy gold, short-sell on banks.

> if u r not ready to help and guide others,
Oh please, just take a look around and figure out just how much help I actually give around here.
Your idea of "help" is something that will get you past the next assignment deadline without fixing any of the underlying problems in your knowledge.
My idea of "help" is to try to get you to work things out for yourself (with some nudging from us). But if you keep bleating "plz, it's too hard", then you're a lost cause.

Comments

Post #12 is as close to an answer on a plate as you're likely to get.

If you can't see the answer from there, just give up at being a C++ programmer.

> why i would come here and bother u to fix such an error!
Because that code WAS CORRECT with an OLD C++ compiler, but it is broken for a NEW C++ compiler. The link I posted (assuming that you haven't read it) explains that (and the reason why).

> this is my work on lab session, i ddnt grab it from any website
> Date: Feb 09, 06
So you're 4 YEARS in the past are you?
Here's a tip for the up-coming financial disaster - sell property, buy gold, short-sell on banks.

> if u r not ready to help and guide others,
Oh please, just take a look around and figure out just how much help I actually give around here.
Your idea of "help" is something that will get you past the next assignment deadline without fixing any of the underlying problems in your knowledge.
My idea of "help" is to try to get you to work things out for yourself (with some nudging from us). But if you keep bleating "plz, it's too hard", then you're a lost cause.

well if u posted the answer and i ddnt understand does that means i'm nt C++ programmer, anyway if u ready 2 explain whatz the right answer then appreciate it.......if not thanx for ur advices and good bye

if your using a for loop (my most common use for i)....then i use this simple method:

(int i = 0; i < 10; i++)

and because its in the local scope of the for loop....you can use it all the time, and its still easy to read :p

Edited 6 Years Ago by Suicidal_tool: n/a

well if u posted the answer and i ddnt understand does that means i'm nt C++ programmer, anyway if u ready 2 explain whatz the right answer then appreciate it.......if not thanx for ur advices and good bye

Sorry to add to this already out of control fire BUT it doesnt really matter what language you have programmed in the past (if any) you always need to declare variables BEFORE you use them.... its not only C++

you always need to declare variables BEFORE you use them.... its not only C++

Your statement is correct for strongly typed languages, but doesn't apply to loosely typed languages such as PHP:

PHP is a loosely typed language

In PHP, a variable does not need to be declared before adding a value to it.

In a strongly typed programming language, you have to declare (define) the type and name of the variable before using it.

In PHP, the variable is declared automatically when you use it.

(Source: http://www.w3schools.com/PHP/php_variables.asp)

Edited 6 Years Ago by mvmalderen: fix wrong word

This article has been dead for over six months. Start a new discussion instead.