Click here to Skip to main content
15,920,632 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Implementing a simple timer. Pin
David Crow16-Nov-06 2:41
David Crow16-Nov-06 2:41 
AnswerRe: Implementing a simple timer. Pin
jmarkey27-Nov-06 13:11
jmarkey27-Nov-06 13:11 
GeneralRe: Implementing a simple timer. Pin
David Crow28-Nov-06 2:32
David Crow28-Nov-06 2:32 
GeneralRe: Implementing a simple timer. Pin
jmarkey29-Nov-06 12:52
jmarkey29-Nov-06 12:52 
GeneralRe: Implementing a simple timer. Pin
David Crow30-Nov-06 3:50
David Crow30-Nov-06 3:50 
GeneralRe: Implementing a simple timer. Pin
jmarkey30-Nov-06 22:09
jmarkey30-Nov-06 22:09 
GeneralRe: Implementing a simple timer. Pin
David Crow1-Dec-06 3:07
David Crow1-Dec-06 3:07 
Questionplz heeeeeeeeeelp meeeeee read/write C++ glopal text files problem Pin
top7ob13-Nov-06 13:07
top7ob13-Nov-06 13:07 
Confused | :confused: hiiiiiiiiiiii..........
Q:
I have in my programe three files: SCANNER.CPP,tst_scanner.cpp and scaner.h
i need read and write from text file which is glopal. how i can do it?
the strange things if i put all programm in one file it is working as good.but whene i use three files it is have error(not define the glopal text file in some file).
i am using many wayes to solve this probleme(i define the glopal text file out of main or enter and enter of getT() or outer of it or the top of any file is .cpp or using 'extern' and....)but i did not get the solve.
pleeeeeeeeeeeeeeeeeeeeez i neeeeeeeeed to know how i do it? if i can opening the text file to be glopal in constructor of my class that good for mee.

NOTE: i need to use this hider of function: Tokens Scanner::getT()

I am writing in SCANNER.CPP this lines code:
#include<iostream>
#include"scanner.h"
#include<fstream>
static char ch;
using namespace std;
extern fstream myfile1;
int lineo=1;
Tokens Scanner::getT()
{
.
.
.
}


-------------and in main file tst_scanner.cpp i write this
#include<iostream>
#include"scanner.h"
#include<fstream>
using namespace std;
int line=1;
static char ch;
//extern fstream myfile1;
int main()

{
//extern fstream myfile1;

fstream myfile2, myfile1; //static fstream myfile1,myfile2;
Scanner S1;
Tokens T1;
myfile1.open( "C:\\fcode.txt", ios::in | ios::out );
myfile2.open( "C:\\fscan.txt", ios::in | ios::out|ios::app );

myfile1.get(ch);
myfile2<<"Tokens_Type"<<"\t\t\t"<<"Line Number"<<"\t\t"<<"Lexmes"<<endl;
do
="" {
="" t1="S1.getT();
" switch(t1.tokentype)
.
.
.
}while
=""
---------------------and="" in="" scaner.h="" i="" write="" this:

typedef="" enum="" {="" tok_ident,tok_il,kw_else,kw_if,kw_int,kw_return,kw_void,kw_while,tok_semicolon,
tok_plus,tok_star,tok_slash,tok_eq,tok_gt,tok_gt_eq,tok_lt,tok_lt_eq,tok_not_eq,tok_assign,tok_lbrace,
tok_rbrace,tok_lbracket,tok_rbracket,tok_lpar,tok_rpar,tok_comma,tok_minus,end,error}tokentypes;
class="" tokens
{
="" friend="" class="" scanner;
="" public:
="" tokentypes="" tokentype="" ;
=""
="" char*="" lexeme;
="" int="" newval;
};

class="" scanner
{
public:

="" scanner();="" constructor
="" tokens="" gett();="" -----------="" return="" object="" of="" (tokens).
="" -----------and="" tokentype,lexeme="" and="" line
};

=""
i="" have="" some="" time="" this="" error="" or="" no="" but="" the="" file="" not="" read="" scanner.cpp
--------------------configuration:="" test_scanner="" -="" win32="" debug--------------------
linking...
scanner.obj="" :="" lnk2001:="" unresolved="" external="" symbol="" "class="" std::basic_fstream<char,struct="" std::char_traits<char=""> > myfile1" (?myfile1@@3V?$basic_fstream@DU?$char_traits@D@std@@@std@@A)
Debug/test_scanner.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

test_scanner.exe - 2 error(s), 0 warning(s)
--------------------------------------------------

thanks for help!!!
AnswerRe: plz heeeeeeeeeelp meeeeee read/write C++ glopal text files problem Pin
Christian Graus13-Nov-06 15:54
protectorChristian Graus13-Nov-06 15:54 
GeneralRe: plz heeeeeeeeeelp meeeeee read/write C++ glopal text files problem Pin
top7ob13-Nov-06 16:45
top7ob13-Nov-06 16:45 
GeneralRe: plz heeeeeeeeeelp meeeeee read/write C++ glopal text files problem Pin
Christian Graus13-Nov-06 16:57
protectorChristian Graus13-Nov-06 16:57 
GeneralRe: plz heeeeeeeeeelp meeeeee read/write C++ glopal text files problem Pin
top7ob13-Nov-06 17:19
top7ob13-Nov-06 17:19 
GeneralRe: plz heeeeeeeeeelp meeeeee read/write C++ glopal text files problem Pin
Christian Graus13-Nov-06 17:25
protectorChristian Graus13-Nov-06 17:25 
GeneralRe: plz heeeeeeeeeelp meeeeee read/write C++ glopal text files problem Pin
top7ob13-Nov-06 18:30
top7ob13-Nov-06 18:30 
GeneralRe: plz heeeeeeeeeelp meeeeee read/write C++ glopal text files problem Pin
Christian Graus13-Nov-06 18:35
protectorChristian Graus13-Nov-06 18:35 
GeneralRe: plz heeeeeeeeeelp meeeeee read/write C++ glopal text files problem Pin
top7ob13-Nov-06 21:15
top7ob13-Nov-06 21:15 
GeneralRe: plz heeeeeeeeeelp meeeeee read/write C++ glopal text files problem Pin
Christian Graus13-Nov-06 21:27
protectorChristian Graus13-Nov-06 21:27 
Questionvery big cstringarray Pin
ayol1212213-Nov-06 12:20
ayol1212213-Nov-06 12:20 
AnswerRe: very big cstringarray Pin
Anthony Mushrow13-Nov-06 12:36
professionalAnthony Mushrow13-Nov-06 12:36 
AnswerRe: very big cstringarray Pin
Mark Salsbery13-Nov-06 13:59
Mark Salsbery13-Nov-06 13:59 
AnswerRe: very big cstringarray Pin
Waldermort13-Nov-06 17:35
Waldermort13-Nov-06 17:35 
GeneralRe: very big cstringarray Pin
ayol1212213-Nov-06 23:56
ayol1212213-Nov-06 23:56 
AnswerRe: very big cstringarray Pin
S Douglas13-Nov-06 19:55
professionalS Douglas13-Nov-06 19:55 
AnswerRe: very big cstringarray Pin
David Crow14-Nov-06 3:29
David Crow14-Nov-06 3:29 
QuestionTerminating a process Pin
Jim Crafton13-Nov-06 9:45
Jim Crafton13-Nov-06 9:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.