Description
Develop the function char** indexedKeysAndOPerators(const char *
fName) with the following specifications :
fName parameter represents the path name of a file + source code C + +.
The return value represents an array of null terminated strings.
For each katholiko block of source code fName there is an element in the table return .
The element is formed from the keywords and the operators of the respective blocks as follows :
Each keyword (keyword) and / or operator (operator) encountered in block numbered and inserted numbered into string.
Different keywords and / or operators have a different numbering . Also , the numbers are different for each block .
The string produced for each ledger(katholiko) block of insertion code will name it representation of keys .
ledger,katholiko = called a code block that is not contained within another block
For EXAMPLE:
#include <iostream>
#include <fstream>
using namespace std ;
void displayFile (const char * fName ) {
//yellow area start
ifstream in;
in.open (fName );
if (!in.is_open ()) {
cout << fName << " not opened" << endl ;
return;
}
char buffer [1024 ];
while (!in.eof ()) {
in.getline (buffer , sizeof (buffer ));
cout << buffer << '\n' ;
}
in.close ();
}
//yellow area finish
int main (){
//green area start
displayFile ("main.cpp" );
return 0;
//green area finish
}
The code above has 2 ledger blocks: the body of displayFile (yellow area) and the body of main (green area).
Therefore, the key representation for the yellow and green blocks are respectively as follows:
The yellow area have keywords as follows: 1 char, 2 cout, 1 endl, 1
if, 1 while and operands: 1 [, 3 (), 5., 2!, 1 return and 5 (.
� Similarly, in the green region have keywords as follows: 1 return and
operators: 1. 1 (.
Accordingly, indexedKeysAndOPerators will return an array of size 2 to
contains the following strings
char1, cout1, cout2, endl1, if1, return1, while 1, [1, ()1, ()2, ()3, !1, !2, (1, (2, (3, (4, (5, .1,
.2, .3, .4, .5
return1, (1, .1
Add a main that takes as a parameter the name of a source code C + + and
will print on the screen the result of indexedKeysAndOPerators.
A list of keywords and operators given in file keywords.txt. The order of
keywords and operators can be changed in keywords.txt if deemed that
facilitate the implementation of indexedKeysAndOPerators.
keywords.txtUnformatted Attachment Preview
Purchase answer to see full attachment