cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Returning short int arr in a function
Returning short int arr in a function
Feb 14, 2014 at 7:23pm UTC
AmitM9S6
(50)
I'm trying to return a short int in a function
This is my function signature :
short
int
* StartRecord(
int
seconds)
this is my array :
short
int
waveIn[NUMPTS];
I'm trying to get the data into an array :
short
int
arr [] = StartRecord(3);
getting this error :
Error 2 error C2440: 'initializing' : cannot convert from 'short *' to 'short []'
Why is that?
Thanks!
Feb 14, 2014 at 7:30pm UTC
Disch
(13742)
Arrays cannot be copied, so you cannot return them from a function.
You'll either have to use a container class (like std::array or std::vector) or will have to pass a pointer to the array into the function as a parameter.
Topic archived. No new replies allowed.