Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C2061: syntax error : identifier '_TCHAR'

Tags:

c++

c

Can't understand why I'm getting this error? im kinda new to c++ and microsoft visual studio, kinda lost on this. Thanks for the help on advance.

#include <iostream>                          
#include <fstream>                           
#include <string>                       
#include <windows.h>                        

using namespace std;
#define STILL_PLAYING   1
#define QUIT            0
#define GAME_FILE "Mundo.txt";

////// the main class of the game, its a room, ull be moving around to other rooms. /////////////
struct posicao{
    string posAtual;
    string Descricao;
    string posNorte;
    string posSul;
    string posLeste;
    string posOeste;
};

/////////// displays the room that you are at the moment /////
void mostraposicao(posicao &posicao)
{
    cout << posicao.Descricao << endl << endl;
}

////////// gets all info of the present room ////
void getPosicaoInfo(posicao &posicao, ifstream fin) {
    string strLine = "";
    string strTemp = "";

    string strPosicao = "<" + posicao.posAtual + ">";
    fin.seekg(NULL, ios::beg);
    fin.clear();

    // reads the txt file line by line till it reaches '*' because
    // the room description is in this format --->> "text '*'"
    // to identify the end of the description.
    while (getline(fin, strLine, '\n')) {
        if (strLine == strPosicao) {
            getline(fin, posicao.Descricao, '*');
            fin >> strTemp >> posicao.posNorte;
            fin >> strTemp >> posicao.posSul;
            fin >> strTemp >> posicao.posLeste;
            fin >> strTemp >> posicao.posOeste;
            return;
        }
    }
}

//// moves to another room////////
void Andar(ifstream fin, posicao &posicao, string strPosicao) {
    if (string == "None") {
        cout << "Você não pode ir por ai!!!" << endl;
        return;
    }
    posicao.posAtual = strPosicao;
    getPosicaoInfo(fin, posicao);
    mostraposicao(posicao);
}

//////////get the input of the player ///////////
int getComando(ifstream fin, posicao &posicao) {
    string strComando = "";
    cout <<endl << ":";
    cin >> strComando;
    if (strComando == "Olhar") {
        mostraposicao(posicao);
    }
    else if(strComando == "Norte") {
        Andar(fin, posicao, posicao.posNorte);
    }
    else if (strComando == "Sul") {
        Andar(fin, posicao, posicao.posSul);
    }
    else if (strComando == "Leste") {
        Andar(fin, posicao, posicao.posLeste);
    }
    else if (strComando == "Oeste") {
        Andar(fin,posicao,posicao.posOeste)
    }
    else if (strComando == "Sair") {
        cout << "Você já desistiu?" << endl;
        return QUIT;
    }
    else if (strComando == "Ajuda" || strComando == "?") {
        cout << endl << "Os comandos do jogo sao : Olhar, Norte, Sul, Leste,Oeste,Sair,Ajuda" << endl;
    }
    else {
        cout << "Ahñ???" << endl;
    }
    return STILL_PLAYNG;
}

///// where the game begins //////////
int _tmain(int argc, _TCHAR* argv[])
{
    ifstream fin;    /// creates the stream file ///
    posicao posicao;   //// the room that will be used in the game ///
    fin.open(GAME_FILE);   ///// gets the text file////
    if (fin.fail())   /////// if the text doesnt exist, the game ends ////
    {
        // Display a error message and return -1 (Quit the program)
        cout << "Jogo não encontrado" << endl;
        return -1;
    }
    // reads twice, so it skips the <start> and reads the <middle>
    // (first room ull be in the game
    fin >> posicao.posAtual >> posicao.posAtual;
    getPosicaoInfo(fin, posicao);
    mostraposicao(posicao);

    /////// if the input its quit, ends the game//////
    while (1) {
        if (getComando(fin, posicao) == QUIT)
            break;
    }
    /////// closes the txt file, ends the game//////////
    fin.close();
    Sleep(3000); /// delays  the close///
    return 0;
}

the text is in this format:

<Start> Middle

<Middle>
You step into a house where you are nearly
blinded by the light shinning through the window.
You have been searching for your friend who was captured.
The trail has led you to this mansion.
There is a door in every direction.*
<north> Top
<east>  Right
<south> Bottom
<west>  Left

<Left>
There is a fountain in the middle of this room.
The cool, crisp air swirls about and encircles you.
There is only one door to the east where you came.*
<north> None
<east>  Middle
<south> None
<west>  None

<Bottom>
You step back outside of the mansion and grab some fresh air.
It is quite refreshing, comapred to the damp smell from within.
You here rustling from the second story of the house.  It could be your friend.
Your only option is to go back inside and get them out of here!*
<north> Middle
<east>  None
<south> None
<west>  None

<Right>
As you pass through the door you feel a chill run
down your spine.  It appears that there something or 
someone or something sitting in the corner, covered by darkness.
There is no where to go but back to the west.*
<north> None
<east>  None
<south> None
<west>  Middle

<Top>
As you get closer to the second story of the mansion, the sounds of someone
struggling can be heard more distinctly.  There is no turning back now.
One door is to the south and one is to the north up a stairwell.*
<north> End
<east>  None
<south> Middle
<west>  None

<End>
You find your friend tied to a chair.  Their hands, feet and mouth are bound,
but it's as if their eyes are screaming at you.  Short bursts of muffled yells
are heard from under the cloth that holds their mouth, as if to say, "Run!".  
What could they be trying to say?  As you walk closer to them they seem to get 
louder and more depserate. That's when you see it.  It had been lurching in the
corner, feathered by darkness.   To be continued...*
<north> None
<east>  None
<south> None
<west>  None
like image 958
Daniel Bezerra De Menezes Avatar asked Mar 25 '15 15:03

Daniel Bezerra De Menezes


1 Answers

You need to include it:

#include "tchar.h"
like image 82
Andrew Komiagin Avatar answered Oct 10 '22 23:10

Andrew Komiagin