Thread: (*ptr)[2] help!!

  1. #1
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751

    (*ptr)[2] help!!

    I'm trying to understand 2d arrays using pointer notation. I've decalred two simple arrays however I get the message
    numeric constant contains digits beyond the radix
    .
    Code:
    #define MAX 5
     int main(void){
     	int array2[MAX][MAX] = { {1,3,4,5,6}, {2,4,1,0,44}, {98,23,32,09,12}, {14,123,99,101,123},
     	{45,87,94,88,43} };
     	int array[MAX] = {34,45,110,56,65};
    What am i missing here?
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Code:
    {98,23,32,09,12}
    On a numeric constent a leading 0 denotes a base 8 number which has valid digits of 0 to 7

  3. #3
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    AHHHHH. I see. I should have remebered that from basic printf modifiers. i didn't think it would matter in an array though. interesting. you learn something new everyday.
    Thanks Thanos.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  4. #4
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    >i didn't think it would matter in an array though.
    It's still an integer literal. Being the initializer for an array makes no difference.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why can't you allocate a 2D array like this?
    By rudyman in forum C++ Programming
    Replies: 7
    Last Post: 07-22-2008, 01:47 PM
  2. lvalue error trying to copy between structures
    By emanresu in forum C Programming
    Replies: 2
    Last Post: 11-16-2006, 06:53 AM
  3. fgets() question
    By caduardo21 in forum C Programming
    Replies: 9
    Last Post: 02-01-2005, 07:03 PM
  4. 2D table problem
    By GaPe in forum C Programming
    Replies: 1
    Last Post: 12-10-2001, 03:52 PM
  5. to quote L@D
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 09-30-2001, 03:04 PM