Hi folks...
I coded my concept like this for the below text file......
<$$$$$$$$$$$$$$$$$$$$$INPUT FILE$$$$$$$$$$$$$$$$>
# c17
# 5 inputs
# 2 outputs
# 0 inverter
# 6 gates ( 6 NANDs )
INPUT(1)
INPUT(2)
INPUT(3)
INPUT(6)
INPUT(7)
OUTPUT(22)
OUTPUT(23)
10 = NAND(1, 3)
11 = NAND(3, 6)
16 = NAND(2, 11)
19 = NAND(11, 7)
22 = NAND(10, 16)
23 = NAND(16, 1)
#include <fstream>
#include <iostream>
#include <limits>
#include <vector>
#include <cctype>
#include <algorithm>
using namespace std;
/*void parse(string dataset)
{
cout<<"New"<<dataset<<endl;
for(string::size_type i=0;i!=dataset.size();++i){
if(isdigit(dataset[i])){
cout<<dataset[i]<<endl;
vObject.push_back(dataset[i]);
}
}
}*/
int main (int argc, const char * argv[])
{
unsigned int i;
ifstream stream;
string my_file = "c17.bench";
string data_set;
vector<float> vObject;
// Open stream.
stream.open(my_file.c_str());
cout<<"stream is>>>>>"<<stream<<endl;
while (!stream.fail())
{
while(stream>>data_set){
// Start looking for Objects.
if (data_set.find( "INPUT" ) != string::npos)
{
/*cout<<data_set<<endl;
parse(data_set);*/
for(string::size_type i=0;i!=data_set.size();++i){
if(isdigit(data_set[i])){
cout<<data_set[i]<<endl;
vObject.push_back(data_set[i]);
}
}
}
}
}
// Print it out.
cout << "Extracted Data is >>>>" << endl;
for (int i = vObject.size(); i>=0;)
{
cout << vObject[i] << endl;//"\t" << vObject[i + 1] << endl;
i -= 1;
}
/*cout << "\n another design Data" << endl;
for (i = 0; i < vObject.size();)
{
cout << vObject[i] << "\n" << vObject[i + 1] << endl;
i += 2;
}*/
// return EXIT_SUCCESS;
}
but the above program generates false output for the following text file given below.....like
49
50
51
52
53
could you please tell me where i did the mistake?
|