pointers - How can I pass a const array or a variable array to a function in C? -


I have a simple function bar which uses a set of values ​​from the data set As an array of data structures Data can come from two sources: a constant initial array of default values, or dynamically updated cache.

The calling function determines which data is used and it is bar . There is no need to edit any data on bar and in fact it should never be done. How should I declare the data parameter of bar so that I can provide data from any set?

  union Foo {long _long; Int _int; } Constant Const Fu Defaults [8] = {1,10,100,1000,10000,100000,1000000,10000000}; Stable fu cache [8] = {0}; Zero bar (Foo * dataSet, int len); // Example Function Prototype  

Note, this is C, not C ++ if it makes a difference;

edit
Oh, one more thing when I use the example prototype, I get a type of qualifier mismatched warning (because I have a contact array I'm passing a temporary reference?). What do I have to change for this?

you want:

  zero times (consu foo * dataset) , Int lane);  

parameter declaration const foo * x meaning:

x is an indicator Fu which I do not want to change.

You will be able to pass a non-contact pointer to bar with this prototype.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -