Hello folks my fstream system appears to have failed!
it all worked until i split the file up into *.H and *.CPP.
// header file
#include <string>
#include <fstream>
#ifndef SCANNER_H
#define SCANNER_H
void openfile(void);
bool check(string token);
bool testing(char sym);
string getsym(void);
#endif
the .cpp file:
string getsym(void)
{
myfile.open("hello.txt");
bool ReserveWord= false;
bool space = false;
string r_token, ksym, test;
string id = "ID";
char next_sym;
if(myfile.is_open())
{
next_sym = myfile.get();
space=testing(next_sym);
if(space)
{
next_sym = myfile.get();
space = testing(next_sym);
while(space)
{
next_sym = myfile.get();
space = testing(next_sym);
}
}
... whilst thats not complete i can only assume its myfile.open(). However if i put that as a global or create a function which opends an iostream to a file, it fails
I've tried the following:
void openmyfile(void)
{
myfile.open("hello.txt");
}
and then called my getsym function, but it doesnt work.... can anyone offer any help?
heres main:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
#include "scanner.h"
string sym;
int main()
{
sym = getsym();
cout << sym;
return 0;
}