this code is reading file which will be given randomnly by our teacher which contains in first line line rows in second line columns and then begins transition table for dfa
then after reading it is stored dynamically in 2d array
then function init creates another array of 128 columns and initializes with -1 at start
then passing 2d array and storing it in this new array
then i have to perform compaction on this array which means columns having same values should be made one
after compaction do traversal of this array
and read another file which contains input string which will be given randomnly by our teacher to generate lexemes tokens
in first row there are ascii values of characters on keyboard and at 128 columns last index accepted state is stored with some number like 101 and rejected state with -1
file is not reading correctly plus i don;t know how to do compaction
i have to check row and column number from file and then on its basis dynamically create an array how to read file and do compaction?
#include "iostream"
#include "fstream"
#include "string"
#define c 6
using namespace std;
void init(int *[],int);//Fuction Prototype
int main()
{
int line=0;
string l;
int rows=5;
int cols=6;
int count=0;
hint... if you read the file in transposed, you can check rows with a memcmp and avoid the double loop and having to track the state of the comparisons in the inner loop. Its a lot simpler that way.