Click here to Skip to main content
14,542,667 members

C / C++ / MFC

 
GeneralRe: Passing an array as argument to a function Pin
fearless_1-Apr-20 1:49
Memberfearless_1-Apr-20 1:49 
GeneralRe: Passing an array as argument to a function Pin
Richard MacCutchan1-Apr-20 2:45
mveRichard MacCutchan1-Apr-20 2:45 
GeneralRe: Passing an array as argument to a function Pin
fearless_1-Apr-20 5:19
Memberfearless_1-Apr-20 5:19 
GeneralRe: Passing an array as argument to a function Pin
Richard MacCutchan1-Apr-20 6:39
mveRichard MacCutchan1-Apr-20 6:39 
GeneralRe: Passing an array as argument to a function Pin
fearless_31-Mar-20 4:42
Memberfearless_31-Mar-20 4:42 
GeneralRe: Passing an array as argument to a function Pin
Richard MacCutchan31-Mar-20 4:58
mveRichard MacCutchan31-Mar-20 4:58 
GeneralRe: Passing an array as argument to a function Pin
fearless_31-Mar-20 5:28
Memberfearless_31-Mar-20 5:28 
AnswerRe: Passing an array as argument to a function Pin
Stefan_Lang30-Mar-20 23:18
mveStefan_Lang30-Mar-20 23:18 
You can do either of these, depending on what you want to do:
// pass read only array of ints
void process_Carray(int const* values, int n_values);
template <int size> // caution: this will create a separate function for each array size!
void process_C11array(std::array<int,size> const& values);
void process_vector(std::vector<int> const& values);
// pass read/write array of ints
void process_Carray(int* values, int n_values);
template <int size> // caution: this will create a separate function for each array size!
void process_C11array(std::array<int,size>& values);
void process_vector(std::vector<int>& values);

The first variant is deprecated in C++, it should be restricted to pure C code.
The second variant is useful if you know the size of your arrays at compile time (and it's always the same)
The third variant is the most flexible as you don't need to know the array size, and you can even add more values within your function if you desire.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

GeneralRe: Passing an array as argument to a function Pin
fearless_31-Mar-20 0:02
Memberfearless_31-Mar-20 0:02 
AnswerRe: Passing an array as argument to a function Pin
fearless_11-Apr-20 5:13
Memberfearless_11-Apr-20 5:13 
GeneralRe: Passing an array as argument to a function Pin
Member 798912211-Apr-20 8:19
MemberMember 798912211-Apr-20 8:19 
QuestionError in BSTR TagVariant After project Migration from VS2010 to VS2017 Pin
Member 1326109427-Mar-20 2:19
MemberMember 1326109427-Mar-20 2:19 
AnswerRe: Error in BSTR TagVariant After project Migration from VS2010 to VS2017 Pin
Victor Nijegorodov27-Mar-20 2:39
MemberVictor Nijegorodov27-Mar-20 2:39 
QuestionRe: Error in BSTR TagVariant After project Migration from VS2010 to VS2017 Pin
CPallini27-Mar-20 3:38
mveCPallini27-Mar-20 3:38 
Questionfatal error LNK1104: cannot open file 'errorStruct.lib' Getting error while compiling application Pin
Member 1326109427-Mar-20 2:12
MemberMember 1326109427-Mar-20 2:12 
SuggestionRe: fatal error LNK1104: cannot open file 'errorStruct.lib' Getting error while compiling application Pin
Richard MacCutchan27-Mar-20 3:03
mveRichard MacCutchan27-Mar-20 3:03 
Questionimplicitly deleted because a base class invokes a deleted or inaccessible function 'CDialog::CDialog(const CDialog &)' Pin
Member 1326109426-Mar-20 22:15
MemberMember 1326109426-Mar-20 22:15 
AnswerRe: implicitly deleted because a base class invokes a deleted or inaccessible function 'CDialog::CDialog(const CDialog &)' Pin
Stephane Capo26-Mar-20 22:50
MemberStephane Capo26-Mar-20 22:50 
GeneralRe: implicitly deleted because a base class invokes a deleted or inaccessible function 'CDialog::CDialog(const CDialog &)' Pin
Member 1326109426-Mar-20 23:26
MemberMember 1326109426-Mar-20 23:26 
QuestionHow to solve the problem with a simple algorithm? Pin
tianzhili439925-Mar-20 23:25
Membertianzhili439925-Mar-20 23:25 
AnswerRe: How to solve the problem with a simple algorithm? Pin
Greg Utas26-Mar-20 0:33
professionalGreg Utas26-Mar-20 0:33 
AnswerRe: How to solve the problem with a simple algorithm? Pin
CPallini26-Mar-20 21:12
mveCPallini26-Mar-20 21:12 
GeneralRe: How to solve the problem with a simple algorithm? Pin
Stefan_Lang26-Mar-20 22:52
mveStefan_Lang26-Mar-20 22:52 
PraiseRe: How to solve the problem with a simple algorithm? Pin
CPallini26-Mar-20 23:16
mveCPallini26-Mar-20 23:16 
AnswerRe: How to solve the problem with a simple algorithm? Pin
Stefan_Lang26-Mar-20 22:47
mveStefan_Lang26-Mar-20 22:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.