Help..Question to mitrmkar .....

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 18
Reputation: EngSara is an unknown quantity at this point 
Solved Threads: 0
EngSara EngSara is offline Offline
Newbie Poster

Help..Question to mitrmkar .....

 
0
  #1
Jul 26th, 2008
Hi...

  1. // read the whole file through one line at a time
  2. while(getline(in, line))
  3. {
  4. // check does this line start with the tag string 'SER(FIT):' ?
  5. // note: there must be no tabs/spaces at the start of the line
  6. if(0 == line.find(tag))
  7. {
  8. // yes it does, then use a
  9. // stringstream object for extracting the values
  10. stringstream sstrm(line);
  11.  
  12.  
  13. if(sstrm >> dummy >> v1 >> v2 >> v3 >> v4 >> v5)
  14. {
  15. // extraction succeeded, now display the values
  16. myfile
  17. << v1
  18. << " "
  19. << v2
  20. << " "
  21. << v3
  22. << " "
  23. << v4
  24. << " "
  25. << v5
  26. << '\n';}
  27.  
  28. else
  29. {
  30. // display an error msg and break ...
  31. myfile << "unexpected: unable to extract 5 values, stopping ...\n";
  32. // break out of the while() loop
  33. break;
  34. }
  35. }
  36. }
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:


  1. Input vector # 1:
  2. OUTPUT: 1 0 1 0 0
  3. **** Vdd = 1.8 **** Tclk = 0.1 ****
  4. SER(FIT): 1.0e-002 1.5e-002 1.5e-002 1.3e-002 5.2e-003
  5.  
  6.  
  7.  
  8. **********************************************************
  9. Input vector # 2:
  10. OUTPUT: 0 0 1 0 0
  11. **** Vdd = 1.8 **** Tclk = 0.1 ****
  12. SER(FIT): 1.0e-002 1.3e-002 1.3e-002 1.4e-002 3.7e-003
  13.  
  14.  
  15.  
  16. **********************************************************
  17. Input vector # 3:
  18. OUTPUT: 0 1 1 1 0
  19. **** Vdd = 1.8 **** Tclk = 0.1 ****
  20. SER(FIT): 8.5e-003 1.2e-002 1.2e-002 1.3e-002 5.2e-003
  21.  
  22. but if i want to change this code to print the numbers of a log file of this format :
  23. Computing SER for individual input vectors...
  24. **********************************************************
  25. Input vector # 1:
  26. OUTPUT: 0 0 0 0 0 0 0 0
  27. **** Vdd = 1.8 **** Tclk = 0 ****
  28. 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
  29. **** Vdd = 1.8 **** Tclk = 0.2 ****
  30. 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
  31. **** Vdd = 1.8 **** Tclk = 0.4 ****
  32. 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
  33. **** Vdd = 1.8 **** Tclk = 0.6 ****
  34. 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
  35. **** Vdd = 1.8 **** Tclk = 0.8 ****
  36. 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
  37. **** Vdd = 1.8 **** Tclk = 1 ****
  38. 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
  39.  
  40.  
  41.  
  42. **********************************************************
  43. Input vector # 2:
  44. OUTPUT: 0 0 0 0 0 0 0 0
  45. **** Vdd = 1.8 **** Tclk = 0 ****
  46. 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
  47. **** Vdd = 1.8 **** Tclk = 0.2 ****
  48. 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
  49. **** Vdd = 1.8 **** Tclk = 0.4 ****
  50. 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
  51. **** Vdd = 1.8 **** Tclk = 0.6 ****
  52. 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
  53. **** Vdd = 1.8 **** Tclk = 0.8 ****
  54. 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
  55. **** Vdd = 1.8 **** Tclk = 1 ****
  56. 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...
Last edited by Tekmaven; Jul 26th, 2008 at 9:07 pm. Reason: Code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Help..Question to mitrmkar .....

 
0
  #2
Jul 27th, 2008
> 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?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC