C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 31st, 2005, 07:26 AM
afzan afzan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 2 afzan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 7 sec
Reputation Power: 0
vector problem

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?

Reply With Quote
  #2  
Old April 1st, 2005, 08:50 AM
afzan afzan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 2 afzan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 7 sec
Reputation Power: 0
Unhappy

guys, i really hope someone can help me out with this..i'm kinda desperate right now. just point me what my mistakes and i'll take the cues from there. i'm not asking you guys to do it for me. all i know is that i've made a mistake in the coding but i'm not sure what it is. please help me

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > vector problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT