0

Hi...

// read the whole file through one line at a time
  while(getline(in, line))
  {
    // check does this line start with the tag string 'SER(FIT):' ?
    // note: there must be no tabs/spaces at the start of the line
    if(0 == line.find(tag))
    {
      // yes it does, then use a 
      // stringstream object for extracting the values
      stringstream sstrm(line);


      if(sstrm >> dummy >> v1 >> v2 >> v3 >> v4 >> v5)
      {
        // extraction succeeded, now display the values
        myfile 
          << v1 
          << "   "
          << v2 
          << "   "
          << v3 
          << "   "
          << v4 
          << "   "
          << v5 
          << '\n';}
      
      else
      {
        // display an error msg and break ...
        myfile << "unexpected: unable to extract 5 values, stopping ...\n";
        // break out of the while() loop
        break;
      }
    }
  }

you gave me this amazing code when i post a thread a bout log files..

but this code only works of file of this format:

Input vector # 1:
OUTPUT: 	1	0	1	0	0	
**** Vdd = 1.8 **** Tclk = 0.1 ****
SER(FIT): 	1.0e-002	1.5e-002	1.5e-002	1.3e-002	5.2e-003	



**********************************************************
Input vector # 2:
OUTPUT: 	0	0	1	0	0	
**** Vdd = 1.8 **** Tclk = 0.1 ****
SER(FIT): 	1.0e-002	1.3e-002	1.3e-002	1.4e-002	3.7e-003	



**********************************************************
Input vector # 3:
OUTPUT: 	0	1	1	1	0	
**** Vdd = 1.8 **** Tclk = 0.1 ****
SER(FIT): 	8.5e-003	1.2e-002	1.2e-002	1.3e-002	5.2e-003	

but if i want to change this code to print the numbers of a log file of this format :
Computing SER for individual input vectors...
**********************************************************
Input vector # 1:
OUTPUT: 	0	0	0	0	0	0	0	0	
**** Vdd = 1.8 **** Tclk = 0 ****
SER(FIT): 	-1.$e+000	-1.$e+000	-1.$e+000	-1.$e+000	-1.$e+000	-1.$e+000	-1.$e+000	-1.$e+000	
**** Vdd = 1.8 **** Tclk = 0.2 ****
SER(FIT): 	2.8e-003	2.8e-003	4.7e-003	5.2e-003	4.2e-003	5.2e-003	2.8e-003	2.8e-003	
**** Vdd = 1.8 **** Tclk = 0.4 ****
SER(FIT): 	2.3e-003	2.3e-003	3.3e-003	3.5e-003	3.1e-003	3.5e-003	2.3e-003	2.3e-003	
**** Vdd = 1.8 **** Tclk = 0.6 ****
SER(FIT): 	2.2e-003	2.2e-003	2.8e-003	3.0e-003	2.7e-003	3.0e-003	2.2e-003	2.2e-003	
**** Vdd = 1.8 **** Tclk = 0.8 ****
SER(FIT): 	2.1e-003	2.1e-003	2.6e-003	2.7e-003	2.5e-003	2.7e-003	2.1e-003	2.1e-003	
**** Vdd = 1.8 **** Tclk = 1 ****
SER(FIT): 	2.0e-003	2.0e-003	2.4e-003	2.5e-003	2.3e-003	2.5e-003	2.0e-003	2.0e-003	



**********************************************************
Input vector # 2:
OUTPUT: 	0	0	0	0	0	0	0	0	
**** Vdd = 1.8 **** Tclk = 0 ****
SER(FIT): 	-1.$e+000	-1.$e+000	-1.$e+000	-1.$e+000	-1.$e+000	-1.$e+000	-1.$e+000	-1.$e+000	
**** Vdd = 1.8 **** Tclk = 0.2 ****
SER(FIT): 	2.8e-003	2.8e-003	4.7e-003	5.2e-003	4.2e-003	5.2e-003	2.8e-003	2.8e-003	
**** Vdd = 1.8 **** Tclk = 0.4 ****
SER(FIT): 	2.3e-003	2.3e-003	3.3e-003	3.5e-003	3.1e-003	3.5e-003	2.3e-003	2.3e-003	
**** Vdd = 1.8 **** Tclk = 0.6 ****
SER(FIT): 	2.2e-003	2.2e-003	2.8e-003	3.0e-003	2.7e-003	3.0e-003	2.2e-003	2.2e-003	
**** Vdd = 1.8 **** Tclk = 0.8 ****
SER(FIT): 	2.1e-003	2.1e-003	2.6e-003	2.7e-003	2.5e-003	2.7e-003	2.1e-003	2.1e-003	
**** Vdd = 1.8 **** Tclk = 1 ****
SER(FIT): 	2.0e-003	2.0e-003	2.4e-003	2.5e-003	2.3e-003	2.5e-003	2.0e-003	2.0e-003

could you please give me an idea on how could i change the code so it works with this file..

and what if the number of outputs is not constant( changes from file to file)...

i tried to do some changes on this code but i failed :(

could you help me please...

Thanks in advanced...

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Salem
0

> you gave me this amazing code when i post a thread a bout log files..
Thanks for pointing out to the rest of us (what some of us already knew) why it is a totally bad idea just to give students code without those students showing some effort.

It seems that two months ago, you took your free cookie and then just left it at that, rather than sitting down and making sure you really understood it. The fact that you called it "amazing" tells us that you still have no clue.

So now you're back with "give me an idea on how could i change the code" and "i tried to do some changes on this code" asking for more free cookies.

> but i failed
Awww - what a shame.
How about posting YOUR attempt (something which you've never done as far as I can tell).

Are you going to leech off mitrmkar for the whole of your course?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.