C++ Can't find error -


not sure i'm doing wrong here. can't run.

    #include "stdafx.h"     #include <iostream>     #include <vector>      using namespace std;     int _tmain(int argc, _tchar* argv[])     {         int a[] = { 2, 3, 4, 5 };         skipone(a, 2);       }      void skipone(int * array, int n)     {         int total = 0;         (int = 0; < sizeof(array); i++)         {             if (i != n)             {                 total = + array[i];             }                    }             cout << "the total is: " << total << endl;     } 

this went below.

#include "stdafx.h" #include <iostream> #include <vector>  using namespace std;  void skipone(vector<int> & array, int n) {      int total = 1;     (int = 0; < array.size(); i++)     {         if (i != n)         {             total *= array[i];         }     }     cout << "the total is: " << total << endl; }  int _tmain(int argc, _tchar* argv[]) {     vector<int> = { 2, 3, 4, 5 };     skipone(a, 0);     skipone(a, 1);     skipone(a, 2);     skipone(a, 3); } 

you need declare skipone earlier , use vector.size()

#include "stdafx.h" #include <iostream> #include <vector>  using namespace std;  void skipone(int * array, int n);  int _tmain(int argc, _tchar* argv[]) {     vector<int> = { 2, 3, 4, 5 };     skipone(a, 2);   }  void skipone(vector<int> & array, int n) {     int total = 0;     (int = 0; < array.size(); i++)     {         if (i != n)         {             total = + array[i];         }                }         cout << "the total is: " << total << endl; }  

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -