0

How do I fix this? **the code I've written is written in the answer section*****

I want to first display the length of the vector and I used the size function And now I want to use the printVect function to show the vectors. But I want to use pointers in displaying it. This is what I have so far. I'm using c++

2nd Dec 2017, 9:35 AM
F7917795
2 Respostas
+ 2
printVec expects 2 parameters and in main you are calling it with just 1 parameter. Remove "s" from where you declared printVec
2nd Dec 2017, 9:56 AM
bogdan
bogdan - avatar
+ 1
#include <iostream> #include <vector> using namespace std; int size (vector<int> nums) { cout << nums.size(); return 0; } int printVec(vector<int>* nums, int s[]) { for (int i=0; i<nums->size(); i++) { cout << (*nums)[i] << endl; } } int main() { vector<int> nums {77, 4, 12, 55, 98}; size(nums); printVec(&nums); return 0; }
2nd Dec 2017, 9:43 AM
F7917795