C++ making an array of zeros?

Hi, Im trying to make an array that will be filled with data later, but I keep getting the following error when compiling:
error: incompatible types in assignment of of 'int*' to 'int[10]'
Im using the following line:
int counter[10]={0}
What needs to be changed? I read everywhere online and this is how they recommend doing it.

Hey guys, I tried all the suggestions provided and they all give me different kind of errors =/
Heres my code, "counter" is the array im trying to make that has a size of "height". can anyone see a reason why Id be getting errors trying to do this?
#include <stdio.h>
#include "CImg.h"
#include <vector>
using namespace cimg_library;
//main program
int main()
CImg<unsigned char> img("xray.jpg");
const unsigned int width = img.dimx();
const unsigned int height = img.dimy();
//converts the image to black and white
img.RGBtoYCbCr().channel(0).resize(-100,-100,1,3).RGBtoLUT(CImg<>(2,1,1,3).fill(0.0f,255.0f),false);
//displays image
CImgDisplay display(img,"Black and White");
while (!display.is_closed)
display.wait();
printf("The height of the image is %d\n",height);
printf("The width of the image is %d\n",width);
//counter array
int counter[10];
std:fill( counter, counter+10, 0);
for (int i=0;i<width;i++)
for (int j=0;j<height;j++)
for (int k=0;k<3;k++)
if (img(i,j,0,k)=0) {
counter=counter+1;
printf("%d",counter);
return 0;

Similar Messages

  • Making existing frequency become zero frequency

    Hye. Help me, I got a probem on making the existing frequency from read from measurement data become zero. Is that possible?
    Because the data should have 0Hz of its frequency. For now it have around 0.05Hz, so i want it to become 0. I has attach my snippet here. Thanks.
    Best regards,
    Fatin.

    I recommend a simple software debounce.  it has been very effective in the past.
    any equipment that vibrates and product spurious edges on a tach or encoder.
    see attached.  it is a modified version of one from NI  set n= 5 0r 10 for your case and see how it works
    Stu McFarlane
    Viewpoint Systems, Inc.
    Attachments:
    debounce.png ‏21 KB

  • Making an Array of Textblocks and displying on the screen when the app is running

    Hello everyone
    I am new to this UI development. I am making a reverse game model and I want show my
    character array contents on text-blocks. I want to make an array of these text-blocks  and show them on screen
    if there is another simple method please suggest me.

    Hello Madhusoodan,
    I'm not sure if you mean WPF application since I haven't saw anything related to WPF. A UI develop can related to so many UI technologies, for example, WPF, WinForm...
    Anyway, if you mean WPF application, you need to know how WPF can add controls at runtime.
    For example, if you have a Grid and want to add textbox, see here:
    https://msdn.microsoft.com/en-us/library/System.Windows.Controls.Grid(v=vs.110).aspx 
    // Add the TextBlock elements to the Grid Children collection
    myGrid.Children.Add(txt1);
    myGrid.Children.Add(txt2);
    myGrid.Children.Add(txt3);
    Just create a loop and put your array of textbox in to the grid:
    textarray[i] = new TextBox();
    textarray[i].Height = 30;
    textarray[i].Width = 50;
    textarray[i].MouseDoubleClick += this.OnMouseDoubleClick;
    uniformGrid1.Children.Add(textarray[i]);
    Regards
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Making an array of different user events refnums?

    Hello all,
    I have a question about dynamic user events. I have 6 different users events which I create, and would like to put into an array. (Such that I can use them in a For loop laters, taking off one event per loop and assigning it to a control of a vi) So far I haven't found a way of doing that since if I just wire the user events refnums to an array I get broken wires. (Similarly if I wire them to a build cluster structure.)
    I think that you'll understand what I am trying to do if you look at my labview code in the attached vi.
    In the vi I create some user events, and then wire them to the control of two vi's which will communicate to each other using these events. In the code you will see 6 Invoke Node structures where I use the "Ctrl Val.set" to pass the events to the two vi's. Obviously this is the wrong why of doing things. Since if instead of having 6 events I had 100, then I would need to put 100 Invoke Node structures on the block diagram (making it very large compared to the size of my computer screen!). 
    So what I would like to do, is put the user events refnums into a array, then put the one Invoke node structure into a For loop, and index the array to assign the events to the vi's programmatically. 
    Is there anyway of doing this? Or is there an alternative (/ better way) to what I have done?
    (Baisically I have 2 vi's that run in parallel and communicate to each other using user events. I need to pass the events to both vi's, how do I do it in the minimum of mouse clicks, and minimum of screen space.)
    Thank you!
    Paul.
    Solved!
    Go to Solution.
    Attachments:
    CameraTempControllerRunner.vi ‏49 KB

    I haven't created any new messages since the forum changed over, so I'm not sure.  But check on the menu under Options on the upper right.  I think there is a way to undo your choice and put it on another.
    Kudo's have replaced the stars.  Anything that was 4 or 5 stars is now equivalent to a Kudo.  But with the old system, anything less than 5 stars was essentially a negative opinion in the ratings.  So to simplify the multiple shades of gray (1 through 4 stars essentially being some degree of a negative) and to just eliminate the negative aspect altogether, the Kudo system was born.
    I don't know if the "Accepted Solution" designation does anything to help the person whose solution was accepted, but having that designation helps people searching the forum because they have the same problem find the answer quicker.
    Message Edited by Ravens Fan on 10-06-2008 10:15 AM

  • Making Condition base value ZERO in RF05L-FWBAS

    SD-FI Integration masters -
    I have a very typical requirement.
    I need to have ZERO tax in Billing.
    I have made the Tax Rate & Tax base Amt ZERO in RV60AFZZ. I have even tried giving a Tax code that has tax rate ZERO.
    Both Invoice & Accounting document both have TAX AMT ZERO  -
    >  BUT
    In an accounting document when I click on Taxes (Radio button) [Display document - Tax Data]
    It shows Base Amt [RF05L-FWBAS].
    Pl let me know where and how I can handle this so it will become ZERO here as well.
    This is creating an issue in Tax Report.
    Thanking you in advance.
    Arun

    Dear Prasaad -
    Thanks for you reply.
    As mentioned earlier, RV60AFZZ has a code that makes Tax %, Tax Base Amt ZERO.
    Even I changed the appropriate tax code that will make everything ZERO.
    Both Invoice and Accounting document DO NOT HAVE TAX AT ALL & RF05L-FWBAS is having a value which I don't want.
    Pl look into this & let me know if you need anything.
    Thanks
    Arun

  • Gui - making an array of JButtons to make a grid

    how do i declare an array of JButtons to make a 16x16 grid? here is an example:
    JPanel grid = new JPanel();
    grid.setLayout (new GridLayout(16,16));
    Container content = frame.getContentPane();
    ImageIcon icon = new ImageIcon("picture.gif");
    JButton[][] element = new JButton[16][16];
    for ( i = 0; i < 16; i++ )
    for ( j = 0; j < 16; j++)
    grid.add(element[i][j].setIcon(icon));
    content.add(grid);
    is that correct at all? it returns this error:
    'void' type not allowed here
    grid.add(elem[i][j].setIcon(icon));
    the caret points to the open parenthesis in setIcon(icon).
    if an array of JButtons doesnt work at all, is there an alternative? my program allows the user to arrange various bricks, etc. to create a maze.

    A 2-dimensional array of JButtons is perfectly possible, provided you write valid Java code. That's all the compiler is complaining about. And also, you forgot to create any button objects to go in the array. Try something like this:for ( i = 0; i < 16; i++ ) {
      for ( j = 0; j < 16; j++) {
        element[i][j] = new JButton();
        element[i][j].setIcon(icon);
        grid.add(element[i][j]);
    content.add(grid);That will get you started. Of course those buttons won't do anything until you add listeners to them, but that's your next challenge, I suppose.
    (By the way, there's a bug in the code that runs this forum. Wherever you see "<i>" in the code, alter it to use the correct rectangular brackets.)

  • Making an Array on or after frame 13 Invisible

    I have a movieClip called "button" within another movieClip called "movie1_mc"
    I want the "button" movieclip, which also loads XML on frame 12 of "movie1_mc to vanish on or after frame 13
    This is the code I have in place but, "button" movieClip isn't disappearing.
    This is my first time using XML and Flash so sorry If I'm way off the mark here.
    //Code to "button movieClip disappear//
    if (_root._currentframe == 13) {
    var linkname:Array = [_visible=false];

    arrays don't have a _visible property.  if the array elements reference objects that do have a _visible property, loop through your array and assign the elements their _visible property.
    also, if you're checking a _currentframe for a timeline, you'll need that to loop unless you only want to check once.

  • Shared variable data type: Can I choose an array of a custom typedef, without making the array itself a typedef?

    Hi all,
    I'd like to pass an array of a cluster across my network. My cluster is typedef'ed, but I'd like to avoid polluting my project with another redundant typedef.
    Is it possible to use the shared variable's "From Custom Control..." option with an array, without saving the array as a new .ctl file?
    Solved!
    Go to Solution.

    Ah, I didn't realize you were using shared variables. I thought you were just considering it as another option along with TCP/IP or UDP or something like that. In this case, you would have to create a second custom control. This control would be an array with teh typedef cluster in it. No need to make this new control itself a typedef though. Sorry, I know you were hoping for a different answer. I doubt one file will really "clutter" your project though
    CLA, LabVIEW Versions 2010-2013

  • Does Reinit To Default set an Array size to zero?

    Does the function Reinit To Default set a 2D Array size to zero? The Help is not explicit on this.
    If not, what is the best way to set a 2D Array size to zero?
    Solved!
    Go to Solution.

    Yes, it sets the size of an array to zero elements, unless the default value is defined otherwise (right click, make current value default.).
    There are several ways to empty an array indicator/control.Normally I write it's value to the terminal or to a local variable. I have never used 'Reinit values to default'
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Is it possible for an Array to have zero element??

    As the subject stated, is it possible for an Array to have zero element apart from being null??
    because if I dont assign an Array to any amount of elements, the Array is always null. And, that is the reason why I never see Array.length being zero.
    Any body can explain??

    As the subject stated, is it possible for an Array to
    have zero element apart from being null??Well, let's see. new int[1] creates an array with one element, so if it IS possible to have an array with zero elements, how do you suppose you'd do that?
    Okay, right.
    Now, what happened when you put that into a .java file and compiled it?
    because if I dont assign an Array to any amount of
    elements, the Array is always null.If you don't assign a reference to an array to your array variable, (i.e. myArr = ... then it will be null (if it's a member variable, but undefined if it's a local).
    But null and empty are not the same thing. Remember, there's your variable, and there's the array it points to.
    Why do you think that the array it points to must have >= 1 elements?
    I'm not saying it's okay to have zero elemnts. And I'm not saying it's not.
    I'm asking you to examine your logic for why you think zero elements is not possible (said logic is faulty). And then I'm asking you to do an experiment to test your theory.
    And, that is the
    reason why I never see Array.length being zero.If you never see array.length being zero, it's because none of the arrays you looked at had zero elments. That doesn't tell you that arrays can't have zero elements.
    So far, you have neither theory nor observations to support either view.

  • Request.getCookies() returns null, not 0 length array

    (reposted from J2EE forum)
    Just upgraded to 9ias with Embedded OC4J and we were getting a NullPointerException.
    Our previous calls to request.getCookies() AKA http://java.sun.com/products/servlet/2.1/api/javax.servlet.http.HttpServletRequest.html#getCookies()
    would return an an array of Cookie Objects or an array of zero length if there are no cookies.
    When we upgraded to 9ias, we got the NPE.
    Know why?
    OC4J implementation of HttpServletRequest doesn't return a zero length array, it returns a null object when there are no cookies!!!
    So we had to change our code to catch this.
    Not a big problem, and it's fixed now, but it was a problem nonetheless.
    Any reason/rationale for why this was done this way? Anyone? Bueller?

    Josh,
    According to Servlet Spec 2.3 (page 193) SRV 15.1.3.2 Methods for (HttpServletRequest SRV.15.1.3) getCookies() returns null if no cookies present. So we are compliant to the spec.
    regards
    Debu Panda
    Oracle That's strange that the NPE problem didn't occurr until deleting cookies on OC4J, then.
    Thanks for responding!

  • Arrays or Spreadshee​ts? Help with School Excercise

    Hello there, my Control Systems Engineering professor will make us a LabView test in a couple of weeks, although he won't actually teach us the software, but rather we need to get our hands dirty. Anyways, I'm trying to resolve this excercise:
    Problem Definition.
    On a storage area of a container terminal containers are stored temporarily waiting for further transportation. The location of a specific container along with its code is stored in a database. Whenever the operator types in the code of a container, the according location is shown on the screen.
    Demands.
    - Take as storing area a rectangle of 3 rows of 4 positions horizontal and 2 positions vertical (24 containers).
    - Each containers is identified by a unique alphanumerical code of 11 digits. Digit # 11 is the check digit, being the last digit of the sum of the previous 10 digits based upon the ASCII table.
    - When filling the database, the user myst apply the code of the container and its location.
    - When searching for a container, the operator applies only the code of the container. On the front panel the according location must be displayed by the program.
    - If a container is not found it must be reported by means of an error message.
    - If an incorrect container code is inserted it must be reported by means of an error message.
    What I've done so far:
    I've made a UI and code so that I can type a 11 digit string and the VI will indicate me if its a valid code or not, based in the comparison of the 11th digit.
    What I need:
    Next step, I believe, is that if the code is valid, I should store it in a database along its position. I know that there is a Database toolkit for LabView, but you must agree it is impractical as this is just an excercise. I was thinking about making an array or a spreadsheet, but have no experience with it. Also it seems that arrays work best with For and While Loops, but I might be wrong... and how can the user assign its position?
    Well, thanks all in advance for ANY suggestions. Everything is welcome.
    Pohl.

    Hello,
    Take a look at the following link:
    http://zone.ni.com/reference/en-XX/help/371361B-01​/lverror/too_few_format_specifiers/
    it explains this error and also gives a link to the format you should use for this function.
    Regards,
    RikP - National Instruments Applications Engineering
    Rik Prins, CLD
    Applications Engineering Specialist Northern Europe, National Instruments
    Please tip your answer providers with kudos.
    Any attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system,
    or for use in hazardous environments. You assume all risks for use of the Code and use of the Code is subject
    to the Sample Code License Terms which can be found at: http://ni.com/samplecodelicense

  • Is there a way to count the number of times an array moves from positive to negative?

    I have an array of values, and I need to find the number of times that the array changes signs (from positive to negative, or vice versa). In other words from a graphical standpoint, how many times a certain line crosses the x-axis. Counting the number of times the array equals zero does not help however, because the array does not always equal exactly zero when it crosses the axis (ie, the points could move from .1 to -.1).
    Thanks for you help. Feel free to email me at [email protected] I only have lv 5.1.1 so if you attach any files, they cannot be version 6.0.

    Attached is a VI showing the # of Pos and Neg numbers in an array, with 0 considered as non-Pos. It is easily modifiable to other parameters - including using the X-axis value as your compare point versus only Zero.
    This is a modified VI from LV (Separate Array.vi)
    Compare this with your other responses to find the best fit.
    Doug
    Attachments:
    arraysizesposneg.vi ‏40 KB

  • Can I have an array of controls without having them in the array front panel holder?

    I would like to link a number of boolean control buttons in an array without grouping them on the front panel the way it does when you make an array and then put in a boolean control.
    Here's the background:
    I have 8 linear motors controlled by CANbus, and so each button type (Move, Stop, Home, etc) is duplicated 8 fold.  I have an event structure that is currently triggered with a separate case for EVERY button with only a very small difference in the code inside each case.  Ideally I could have the buttons in arrays and then check the new array value against the old value on a value change event.  The alternative for me is to have each case handle the 8 buttons (with a Mouse Down? filter event) and then use the Boolean.Text value from the CtlRef and search an array of all Boolean.Text Values for the 8 buttons to see which name matches and process accordingly.  I have something like 200 buttons, so making the arrays of Boolean.Text values from the reference nodes is WAY too time consuming as I have to go through like 5 levels of right click menus.  Any suggestions?  

    Mark,
    You might consider using clusters on the front panel.  Create a type def'd cluster that has all the boolean controls for 1 channel.  You can drop 8 of these on the front panel and the event structure can detect a change in a cluster.  Easy to convert cluster to array behind the scenes.  Remember that order of cluster determines index of value in array.
    Message Edited by Wayne.C on 04-09-2010 05:19 PM

  • How do you make an array of image icons and then call them?

    How do you make an array of image icons and then call them, i have searched all over the internet for making an array of icons, but i have
    found nothing. Below is my attempt at making an array of icons, but i cant seem to make it work. Basically, i want the image to match the value of the roll of the dice (rollVal)
    Any help would be greatly appreciated, some code or link to tuturial, ect.
    /** DiceRoller.java
    * Roll, print, Gui
    import javax.swing.*;
    public class DiceRoller extends JFrame
         private ImageIcon[] image  ;
         public String[] images = { "empty", "dice1.jpg",
                   "dice2.jpg", "dice3.jpg", "dice4.jpg",
                   "dice5.jpg", "dice6.jpg" };
         public Dice die;
         private int rollVal;
         public int rollNum;
         private JLabel j1;
         public DiceRoller(){
              j1= new JLabel("");
           die =new Dice();
           int rollVal;
           rollVal = die.roll();     
           image = new  ImageIcon[images.length];
         for(int i = 0; i < images.length; i++){
          image[i] = new ImageIcon(images);
         if (image!=null){
              j1.setIcon(image[rollVal]);
         System.out.println("Roll = "+die.roll());

    Demo:
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    public class IconExample {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch();
        static void launch() {
            try {
                Icon[] icons = new Icon[6];
                for(int i=0; i<icons.length; ++i) {
                    String url = "http://www.eureka-puzzle.be/cast/images/dice" + (i + 1) + ".jpg";
                    icons[i] = new ImageIcon(new URL(url));
                display(icons);
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
        static void display(Icon[] icons) {
            JPanel cp = new JPanel();
            for(Icon icon : icons) {
                cp.add(new JLabel(icon));
            JFrame f = new JFrame();
            f.setContentPane(cp);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

Maybe you are looking for