GIDForums

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Mar-2008, 01:01
Aamit Aamit is offline
New Member
 
Join Date: Mar 2008
Posts: 3
Aamit is on a distinguished road

Read value Below "MEAN" in C


How to read value Below "MEAN" in c??
I want to read CEL file and display numbers below Mean column.?
Contain in CEL file are

[CEL]
Version=3
[HEADER]
Cols=744 Rows=744
TotalX=744 TotalY=744
OffsetX=0 OffsetY=0
GridCornerUL=1 1
GridCornerUR=744 1
GridCornerLR=744 744
GridCornerLL=1 744
Axis-invertX=0
AxisInvertY=0
swapXY=0
DatHeader=   U133AAofAv2.1sq  
Algorithm=Percentile
AlgorithmParameters=Perce...

[INTENSITY]
NumberCells=553536
Cell Header=X Y MEAN STDV NPIXELS
0 0 717.5 212.2 36
1 0 28103.0 6666.0 36
2 0 908.3 211.7 36
- -------------------- upto----
743 0 219.0 122.3

My code is---->
CPP / C++ / C Code:
#include<iostream>
#include<fstream>
#include<string>
#include<stdio.h>
#include<conio.h>

using namespace std;
int data(int);
int main()
{
    char my_char;
    int i;
    // ask user for the files
    size_t counter(0); // how many found
    string if_name;
    string of_name;
    cout << "Enter the name of the file to read, including file extention" << endl;
    cin >> if_name;
    cout << "and the file to write to" << endl;
    cin >> of_name;
    
    // clear iostate just in case and open file
    ifstream in_file;
    ofstream out_file;
    in_file.close();
    in_file.clear();
    out_file.close();
    out_file.clear();
    
    in_file.open(if_name.c_str(), ifstream::in);
    out_file.open(of_name.c_str(), ofstream::out | ofstream::ate);
    long ab;
     
     if((in_file.is_open()) && (out_file.is_open()))
    {
        cout << "Open complete" << endl;

    // achive goal
    string content;
    string word;
 
 //   static unsigned int line_no = 1;  
    const int word_length = word.size();
    char word_copy[(word_length + 1)];
    size_t found;
    int str_length;
    
    cout << "What string do you want to find? " << endl;
    cin >> word;

    while(getline(in_file, content) || (!in_file.eof()))
    {             
                static unsigned int line_no = 1; 
                      
                found = content.find(word.c_str());
           // getch();
            if (found != string::npos)
            {
                cout << "Match found in line " << line_no << " at: " << found << endl;        
                ++counter; 
                for(i=0;i<744;i++)
                {
                    //while(my_char!='\n')
                    in_file>>my_char;
                    
                    while((!in_file.eof()) && (my_char != '\n'))
                    {
                    my_char = in_file.get() ;
                    cout<<my_char; //Here i get all data
                   // getch();
                    }
                }    
                          line_no=line_no+1;   
                    printf("\n%d",line_no);
                
                     
                
              //  data(line_no);    
                str_length = content.copy(word_copy, word_length, found); 
                word_copy[str_length]= '\0';  
                cout << "\nword_copy: " << word_copy << endl; 
                break;
                // out_file << word_copy << endl;
        
             }
              else {
                       //cout << "NO match found in line "<<endl; 
                                                        
                       //getch();
                       } // end second if
            ++line_no;     
            
            
            } // end while loop              
           
           
    in_file.close();
    out_file.close();

    }
        
    else
     {                 
        cout << "Open failed.";
         getch();
        } // end first if
        

    cout << "The string was found " << counter << " times in the file " << endl;
         
   getch();
    
}

int data(int a)
{
    printf("\nIN data");
    int x=a+1;
    printf("\n%d",x);
    
}

But want out put like
0 212.2
1 6666.0
2 211.7
3 6829.7
4 170.8
-------------
743 5785.3
Last edited by admin II : 27-Mar-2008 at 04:01. Reason: Please surround your C++ code with [cpp] your code [/cpp]
  #2  
Old 27-Mar-2008, 01:02
Aamit Aamit is offline
New Member
 
Join Date: Mar 2008
Posts: 3
Aamit is on a distinguished road

Re: Need help??


Plz give me some sugession on this??
 

Recent GIDBlogMaster?s Degree by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:27.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.