tic tac toe help

C:\Documents and Settings\Matt\My Documents\tictactoe.c|1|error: iostream: No such file or directory|
C:\Documents and Settings\Matt\My Documents\tictactoe.c|2|error: cstdlib: No such file or directory|
C:\Documents and Settings\Matt\My Documents\tictactoe.c|3|error: ctime: No such file or directory|
C:\Documents and Settings\Matt\My Documents\tictactoe.c|4|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'|
C:\Documents and Settings\Matt\My Documents\tictactoe.c||In function 'main':|
C:\Documents and Settings\Matt\My Documents\tictactoe.c|10|error: 'cout' undeclared (first use in this function)|
C:\Documents and Settings\Matt\My Documents\tictactoe.c|10|error: (Each undeclared identifier is reported only once|
C:\Documents and Settings\Matt\My Documents\tictactoe.c|10|error: for each function it appears in.)|
C:\Documents and Settings\Matt\My Documents\tictactoe.c|11|error: 'cin' undeclared (first use in this function)|
C:\Documents and Settings\Matt\My Documents\tictactoe.c|12|error: 'endl' undeclared (first use in this function)|
||=== Build finished: 9 errors, 0 warnings ===|


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{
    char r,  p,  s,  name;

    cout << "user: please enter your name- ";
    cin >> name;
    cout << "hello " << name << "!!!" << endl;

    system("pause");
    return 0;
}
Last edited on
Did you compile it as C++ code?
yes i did
it works on dev c++ but not on code:: blocks
It's bad code. However, the reason it's failing for you is that YOU'RE COMPILING IT AS C CODE. You've named your file tictactoe.c and your compiler thinks it's C code.

name is a single char. What happens when someone enters more than a single char?

system("pause"); This is BAD. How many times do we have to tell you? Why do you come here to ask questions if you refuse to listen to the answers?

Dev-C++ is bad. BAD BAD BAD. How many times do we have to say it to you? If you insist on using Dev-C++, there is a more recent (unofficial - done by some other guy) one that is better. http://orwellengine.blogspot.com/

Last edited on
im done using dev c++.i was just using dev c++ because i was trying to figure out why code::blocks wasnt working. and what should i use instead of system("pause")
and how do i switch it to c++ instead of c
what should i use instead of system("pause")


If you can't simply run it from the command line, try the suggestion here: http://www.gidnetwork.com/b-61.html

and how do i switch it to c++ instead of c

I suspect it's basing its guess of what language you're using on the file extension. Make sure the name of the file ends with .cpp
Easiest way is to change the file extension from .c to .cpp

system("pause") works but you should know that it only works properly on windows.
What can I use instead of system ("pause")?

http://www.cplusplus.com/forum/beginner/1988/

And yes you should switch to C++.
Topic archived. No new replies allowed.