Reading Numbers into an Array C++

Code with C | Programming: Projects & Source Codes Forums C and C++ Reading Numbers into an Array C++

This topic contains 1 reply, has 1 voice, and was last updated by  ShikhaTan 2 years, 6 months ago.

  • Author
    Posts
  • #10846

    Miranda65M
    Member

    So I’m just starting out in C++ and I managed to convert an image into a text file which contains: x y intensity values.

    So this is an example of the file:

    The code I’m writing is in C++ but is actually processed in root.

    The code I’ve started writing is:

    Now the part with "p001_1->" is where I'm tripping up, ultimately I'd like an array that looks something like this:

    where I can pick which x,y values I want for it to spit out the intensity value. The only catch is I need those x,y values to correspond to the values in the file. I know I'm close, but I just need a little help over the final hurdle =P

    THANKS =)

    P.S I've sort of found a solution:

    Code: Select all
    p001_1->SetBinContent(x,y,intensity);

    BUT this isn't brilliant for what I need it for next (taking certain areas of the picture and finding the difference of the intensities)

    EDIT:

    but then I get this error:

    I appreciate you don't know the line numbers, but I think it really doesn't like the way I'm defining the variables

  • #10847

    ShikhaTan
    Member

    So on http://root.cern.ch/root/html/src/TH2D.h.html#kvMDeC

    It seems to be saying there is a function for:

    So wouldn’t you be able to just use that instead of making the array of doubles?

    But if you really want to make the array of doubles, I don’t think you can initialize with

    I think you’d need to use

    You can see this in the error where it says the operand of comma has no effect and that it expects to see an end bracket

You must be logged in to reply to this topic.