Sunday 15 September 2013

c++ - Error LNK2019 with pointers -



c++ - Error LNK2019 with pointers -

this question has reply here:

what undefined reference/unresolved external symbol error , how prepare it? 23 answers

i create function expands array using pointers , function. rather new coding in general , uncertain why getting error lnk2019. aware means there unresolved external, have changed on same error keeps popping up. here code...

#include <iostream> #include <iomanip> #include <string> #include <cmath> #include <fstream> #include <vector> using namespace std; int * newarray(int[], int); int main() { int arr[] = { 12, 21, 56, 49, 72, 18 }; newarray(arr, 10); homecoming 0; } int * newarray(int arr, int size) { int *p; int arr2; int *amount = new int[size * 2]; amount = &arr2; int i; p = &arr; (i = 0; i<size * 2; i++) { if (i<size) { amount[i] = p[i]; } else { amount[i] = 0; } } arr = arr2; homecoming amount; }

normally rather pass variable reference need utilize pointer this, if point me in right direction much appreciated.

there many errors in code. of these goes :-

int * newarray(int arr, int size)

you accepting array int. should be

int * newarray(int* arr, int size)

second 1

arr = arr2;

arr int* , arr2 int.

c++ c

No comments:

Post a Comment