Thread: Why this comma?

  1. #1
    Registered User
    Join Date
    Jul 2020
    Posts
    3

    Why this comma?

    Does anyone know what is the purpose of this comma:
    Code:
    static uint8_t test[] = {0,};

  2. #2
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948
    Is this generated code? I don't know the reason for this particular comma, but I often write code generators that put a comma after each array element like the following:

    Code:
    int foo[] = {
      1,
      2,
      3,
    };
    so the code generator doesn't have to worry about whether each element is the last or if there are more following it. C and C++ allow the last element to have a comma after it which makes this possible (and convenient).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Comma operator
    By ssharish2005 in forum C Programming
    Replies: 2
    Last Post: 10-20-2010, 05:35 AM
  2. comma operator
    By raghuveerd in forum C Programming
    Replies: 5
    Last Post: 07-09-2007, 04:52 AM
  3. Number WITH appropriate comma's
    By Adak in forum C Programming
    Replies: 5
    Last Post: 06-16-2007, 11:31 PM
  4. comma
    By hug in forum C# Programming
    Replies: 1
    Last Post: 12-14-2002, 10:48 AM
  5. Replace "." (dot-comma) with "," (regular-comma) for MS Excel
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 03-20-2002, 01:39 AM

Tags for this Thread