Thread: How to set default value in arry

  1. #1

    How to set default value in arry


    I am seeing error C2440: '=' : cannot convert from 'nuint8' to 'nuint8 [32]' in the following snippet of code. I am trying to set default values for optional arguments but cannot fugure out how to set the default value for the array ASNData.

    //nuint32 is unsigned char

    typedef struct
    nuint32 attrFlags ;
    nint32 attrSyntaxID ;
    nint32 attrLower ;
    nint32 attrUpper ;
    Asn1ID asn1ID ;
    } AttrInfo;

    typedef struct
    nuint32 length;
    nuint8 data [32];
    } Asn1ID;

    // db.cpp
    int DB::AddToDB(pnstr8 Name, nuint32 Flags,
    nint32 Syntax , nint32 RangeL,
    nint32 RangeU , nuint8 ASNData,
    nuint32 ASNLenth)

    AttrDefs.attrFlags = Flags;
    AttrDefs.attrSyntaxID = Syntax;
    AttrDefs.attrLower = RangeL;
    AttrDefs.attrUpper = RangeU; = ASNData; // c2440 here
    AttrDefs.asn1ID.length = ASNLenth;

    // db.h

    AttrInfo AttrDefs;
    int AddToDB(pnstr8 Name, nuint32 Flags, nint32 Syntax,
    nint32 RangeL = 0, nint32 RangeU = 0, nuint8 ASNData "what goes here!",
    nuint32 ASNLenth = 0);

    AddToDb is called like so

    AddToDB("Joe Bloggs", STRING_ATTR, CI_STRING);

    To anyone who can help, thanks Paul C,,

  2. #2
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    You a) Have to loop through and set each individual value b) When you declare the array, do so like this: int array[0xBAD] = { 0 };

  3. #3
    I tried that in the db.h file but i get an "overloaded function not found" error.

    What I am trying to achive is to set ASNData[32] to 0 if ASNData is not supplied to the function. But I,m stuck!!

    int AddToDB(pnstr8 Name, nuint32 Flags, nint32 Syntax,
    nint32 RangeL = 0, nint32 RangeU = 0, nuint8 ASNData[32] = {0},
    nuint32 ASNLenth = 0);


  4. #4
    Registered User
    Join Date
    Oct 2001
    > = ASNData; // c2440 here
    nuint32 i;
    for (i=0; i<ASNLenth; i++)[i] = ASNData;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C help for network animator
    By fastshadow in forum Tech Board
    Replies: 7
    Last Post: 03-17-2006, 03:44 AM
  2. How to set default argurments for function?
    By megablue in forum C Programming
    Replies: 5
    Last Post: 09-09-2004, 07:46 AM
  3. opengl help
    By heat511 in forum Game Programming
    Replies: 4
    Last Post: 04-05-2004, 01:08 AM
  4. Replies: 5
    Last Post: 09-03-2001, 09:45 PM