Calling a function with an array inside it
Sep 21, 2015 at 3:12pm Sep 21, 2015 at 3:12pm UTC
Hey, my question is simple. How do I call a function if I want to bring my array from my previous function? I tried this below, but it doesn't work, I get the error "argument of type 'char' is incompatible with parameter of type 'char *'".
I appreciate any answers, thanks a lot! :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <iostream>
using namespace std;
void func(int valueC, char anArray[]);
int main()
{
const int valueA = 20, valueB = 20;
const int valueC = valueA * valueB;
char anArray[valueC];
func(valueC, anArray[valueC]);
}
void func(int valueC, char anArray[])
{
//code
}
Sep 21, 2015 at 3:38pm Sep 21, 2015 at 3:38pm UTC
func(valueC, anArray);
Sep 21, 2015 at 3:52pm Sep 21, 2015 at 3:52pm UTC
Lets say I had give the array different values before calling the function. Would I be able to use it like this, without giving it new values?
Topic archived. No new replies allowed.