| | |
Help..Question to mitrmkar .....
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2008
Posts: 18
Reputation:
Solved Threads: 0
Hi...
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:
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...
C++ Syntax (Toggle Plain Text)
// 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; } } }
but this code only works of file of this format:
C++ Syntax (Toggle Plain Text)
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...
Last edited by Tekmaven; Jul 26th, 2008 at 9:07 pm. Reason: Code tags
> 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?
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?
![]() |
Similar Threads
- Improvement / Shorter code? (C++)
- MessageBox with OK and CancelButton (C++)
- Please Help. (C)
- Vector Question (C++)
Other Threads in the C++ Forum
- Previous Thread: namespaces
- Next Thread: Simple Bubble sort C++ function
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






