displaying data

This is a discussion on displaying data within the C++ Programming forums, part of the General Programming Boards category; how can i display Cluster1[0][n]in .dat file?Below is my code.. Code: ... for(int j=0;j<DataHeight;j++) { for(int i=0;i<DataWidth;i++) { Data[i][j]=(unsigned char)(((float)dataconv[j][i]-min)/(max-min)*255); ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    8

    displaying data

    how can i display Cluster1[0][n]in .dat file?Below is my code..
    Code:
    ... 
    for(int j=0;j<DataHeight;j++) 
    { 
    for(int i=0;i<DataWidth;i++) 
    { 
    Data[i][j]=(unsigned char)(((float)dataconv[j][i]-min)/(max-min)*255); 
    if (Data[i][j]==170) 
    { 
    Cluster1[0][n]=Data[i][j]; 
    n++; 
    } 
    } 
    }

  2. #2
    Registered User
    Join Date
    Oct 2003
    Posts
    8

    continue...

    i'm using C++ Builder version 5.0

  3. #3
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    Code:
    #include <fstream>
    ...
    std :: ofstream save("save.dat");
    save << Cluster1[0][n];
    save.close();
    ...
    Like that, you mean?

    - SirCrono6
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    8
    yup..and do i have to add something before/after the code?i'm just a beginner in this programming area..

  5. #5
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    do you want to save just that one array element, or the whole array (of arrays)?

    to save every element in the arrays:
    Code:
    #include <fstream>
    ...
    int main() {
         ...
         std :: ofstream save("ofile.dat");
         for(int x=0;x<MAX_X;x--) //you define MAX_X somewhere else
         {
              for(int y=0;y<MAX_Y;y--)  //you define MAX_Y somewhere else
                   ofile << Cluster1[x][y];
         }
         ofile.close();
         ...
    } //end of main()
    ...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 11:13 AM
  2. Replies: 3
    Last Post: 04-18-2008, 11:06 AM
  3. question about a working linked list
    By cold_dog in forum C++ Programming
    Replies: 23
    Last Post: 09-13-2006, 02:00 AM
  4. Replies: 4
    Last Post: 06-14-2005, 06:45 AM
  5. All u wanted to know about data types&more
    By SAMSAM in forum Windows Programming
    Replies: 6
    Last Post: 03-11-2003, 03:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21