hi guys. i'm having problems with vectors. i don't know whether my syntax is rcorrect or not as this is my forst time using vector.
here's a portion of my codes.
Code:
#include <iostream>
#include <windows.h>
#include <conio>
#include <string>
#include <vector>
#include <dos.h>
#include <bios.h>
#include <stdio>
//#include <math.h>
#include <time>
#include "tokenizer.h"
using namespace std;
void end();
void design();
void main()
{
char menu;
ifstream infile;
do
{
int i, x, j=223;
struct time t;
HANDLE hOut;
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTitle("TESCAGEN Ver 1.0");
clrscr();
design();
textcolor(YELLOW);
gotoxy(24,3);
cprintf("\xDB\xDB\xDB\xDB\xB2 TESCAGEN Ver 1.0 alpha \xB2\xDB\xDB\xDB\xDB");
gotoxy(5,5);
for(i=0;i<70;i++)
cprintf("%c",j);
gotoxy(35,6);
cprintf("MAIN MENU");
gotoxy(26,8);
cprintf(" [S] - START (read file)");
gotoxy(26,9);
cprintf(" [Q] - QUIT PROGRAM\n");
gotoxy(26,10);
gotoxy(26, 18);
gettime(&t);
printf("The current time is: %2d:%02d:%02d.%02d\n",
t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
gotoxy(26, 23);
cprintf("SELECT AN OPTION: ");
gotoxy(44,23); //cursor
cin>>menu;
if(isalpha(menu))
switch(menu)
{
case 'S':
case 's':
//clrscr();
cout<<"\n\n";
infile.open("ass.txt");
string line;
vector <string> tokens;
bool endOfFile = infile.eof();
int count =0;
/*string i[4];
i[0]="if(i==1||i==x)";
i[1]="else if(j==1||j==x)";
i[2]="else if(j==i)";
i[3]="while(x!=20)";*/
vector <string> ident;
ident.push_back("if(x<5||x>20)");
ident.push_back("if(i==1||i==x)");
ident.push_back("else if(j==1||j==x)");
ident.push_back("else if(j==i)");
ident.push_back("while(x!=20)");
vector <string> test;
test.push_back("Possible test cases: x>5, x==5, x!=5, x<20, x==20, x!=20");
test.push_back("Possible test cases: i<1, i>1, i!=1, i<x, i>x, i!=x");
test.push_back("Possible test cases: j<1, j>1, j!=1, j<x, j>x, j!=x");
test.push_back("Possible test cases: j<i, j>i, j!=i");
test.push_back("Possible test cases: x<20, x>20, x==20");
while(!endOfFile)
{
endOfFile = getStringAndTokens(infile, line, tokens);
if(!endOfFile)
{
count++;
cout<<count<<")"<<line<<endl<<endl;
if(!ident.empty()) //compare identifiers and tokens
{
for(int i=0; i<tokens.size(); i++)
{
for(int d=0; d<ident.size(); d++)
{
for(int c=0; c<test.size(); c++)
{
if(tokens[i] != ident[d])
{
ident.push_back(tokens[i]);
}
else if(ident[d]==test[c])
{
ident.push_back(test[c]);
}
}
}
}
}
//end if !ident.empty()
for(int i=0;i<tokens.size();i++) //tokenizing words
{
cout<<tokens[i]<<endl;
}
cout<<"\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n"<<endl;
ifstream(infile);
system("Pause");
}
//end if !eof
} //end while !eof
getch();
break;
} //end switch
else
cout<<"\t\t Wrong key in. Please try again.\n\n";
}while(menu!='q'&& menu!='Q');
end(); //end do
} //end main
void end()
{
int i, x, j=223;
clrscr();
design();
textcolor(YELLOW);
gotoxy(5,5);
for(i=0;i<70;i++)
cprintf("%c",j);
gotoxy(24,3);
cprintf("\xDB\xDB\xDB\xDB\xB2 TESCAGEN Ver 1.0 alpha \xB2\xDB\xDB\xDB\xDB");
gotoxy(5,5);
gotoxy(26,10);
cprintf("Thank you for using this program!");
gotoxy(26,11);
cprintf("Coded by: Aizatul Afzan bt. Ibrahim\n");
gotoxy(26,12);
cprintf("Email: zaxry_rugrats83@yahoo.com");
gotoxy(26,13);
getch();
exit(0);
}
void design()
{
int i;
clrscr();
textcolor(14);
gotoxy(2,2);
cprintf("\xC9");
gotoxy(3,2);
for(i=1;i<=74;i++)
cprintf("\xCD");
gotoxy(77,2);
cprintf("\xBB");
gotoxy(2,3);
cprintf("\xBA");gotoxy(2,4);cprintf("\xBA");gotoxy(2,5);cprintf("\xBA");
gotoxy(2,6);cprintf("\xBA");gotoxy(2,7);cprintf("\xBA");gotoxy(2,8);cprintf("\xBA");
gotoxy(2,9);cprintf("\xBA");gotoxy(2,10);cprintf("\xBA");gotoxy(2,11);cprintf("\xBA");gotoxy(2,12);cprintf("\xBA");
gotoxy(2,13);cprintf("\xBA");gotoxy(2,14);cprintf("\xBA");gotoxy(2,15);cprintf("\xBA");gotoxy(2,16);cprintf("\xBA");
gotoxy(2,17);cprintf("\xBA");gotoxy(2,18);cprintf("\xBA");gotoxy(2,22);cprintf("\xCC");
gotoxy(2,19);cprintf("\xBA");gotoxy(2,20);cprintf("\xBA");gotoxy(2,21);cprintf("\xBA");gotoxy(2,24);cprintf("\xC8");
gotoxy(2,23);cprintf("\xBA");
gotoxy(3,24);
for(i=1;i<=74;i++)
cprintf("\xCD");
gotoxy(77,18);cprintf("\xBA");gotoxy(77,19);cprintf("\xBA");gotoxy(77,20);cprintf("\xBA");gotoxy(77,21);cprintf("\xBA");gotoxy(77,24);cprintf("\xBC");
gotoxy(77,23);
cprintf("\xBA");
gotoxy(3,22);
for(i=1;i<=74;i++)
cprintf("\xCD");
gotoxy(77,22);
cprintf("\xB9");
gotoxy(77,3);
cprintf("\xBA");gotoxy(77,4);cprintf("\xBA");gotoxy(77,5);cprintf("\xBA");
gotoxy(77,6);cprintf("\xBA");gotoxy(77,7);cprintf("\xBA");gotoxy(77,8);cprintf("\xBA");
gotoxy(77,9);cprintf("\xBA");gotoxy(77,10);cprintf("\xBA");gotoxy(77,11);cprintf("\xBA");gotoxy(77,12);cprintf("\xBA");
gotoxy(77,13);cprintf("\xBA");gotoxy(77,14);cprintf("\xBA");gotoxy(77,15);cprintf("\xBA");gotoxy(77,16);cprintf("\xBA");
gotoxy(77,17);cprintf("\xBA");
}
i'm developing a test case generator that incorporates black box testing strategy and white box testing strategy. the problem is that i can't seem to display the
test cases. i've bolded a portion of codes that i think is incorrect. can someone tell me what is wrong with my codes?