passing vector by reference huge problems

Discussion in 'C Programming' started by vkaul1, Jun 26, 2009.

  1. vkaul1

    vkaul1

    Joined:
    Jun 26, 2009
    Messages:
    1
    I am not able to pass vector by reference if I read it from a txt file and populate it. What is wrong with the code here

    #include <iostream>
    #include <fstream>
    #include <vector>
    #include <math.h>


    void signedDistanceTransform2D(vector<int> &iContour);
    using namespace std;

    int main()
    {
    fstream infile("crack_index.txt");
    vector<int> iContour;
    if(!infile)
    { cout<<"Error opening output file"<<endl;
    system("pause");
    return -1;
    }
    else
    { int C_point=0;
    // checking for the current point
    while(infile>> C_point)
    {
    //putting the initial crack points in the vector
    iContour.push_back(C_point);



    }


    signedDistanceTransform2D(iContour);

    return 0;
    }
    }


    void signedDistanceTransform2D(vector<int> &iContour) {}



    It is throwing errors like which is bizarre

    \Users\vivek\Documents\main.cpp(7) : error C2065: 'vector' : undeclared identifier
    C:\Users\vivek\Documents\main.cpp(7) : error C2062: type 'int' unexpected
    C:\Users\vivek\Documents\main.cpp(13) : error C2872: 'vector' : ambiguous symbol
    C:\Users\vivek\Documents\main.cpp(13) : error C2872: 'vector' : ambiguous symbol
    C:\Users\vivek\Documents\main.cpp(13) : error C2062: type 'int' unexpected
    C:\Users\vivek\Documents\main.cpp(25) : error C2065: 'iContour' : undeclared identifier
    C:\Users\vivek\Documents\main.cpp(25) : error C2228: left of '.push_back' must have class/struct/union type
    C:\Users\vivek\Documents\main.cpp(32) : error C2065: 'signedDistanceTransform2D' : undeclared identifier
    C:\Users\vivek\Documents\main.cpp(43) : error C2872: 'vector' : ambiguous symbol
    C:\Users\vivek\Documents\main.cpp(43) : error C2872: 'vector' : ambiguous symbol
    C:\Users\vivek\Documents\main.cpp(43) : error C2062: type 'int' unexpected
    C:\Users\vivek\Documents\main.cpp(43) : error C2143: syntax error : missing ';' before '{'
    C:\Users\vivek\Documents\main.cpp(43) : error C2447: missing function header (old-style formal list?)
    Error executing cl.exe.

    main.obj - 13 error(s), 0 warning(s)
    vkaul1, Jun 26, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pmatos
    Replies:
    6
    Views:
    23,772
  2. Allerdyce.John@gmail.com
    Replies:
    8
    Views:
    1,913
    Csaba
    Feb 18, 2006
  3. Javier
    Replies:
    2
    Views:
    558
    James Kanze
    Sep 4, 2007
  4. tejsupra@gmail.com

    Memory error due to the huge/huge input file size

    tejsupra@gmail.com, Nov 10, 2008, in forum: Python
    Replies:
    3
    Views:
    490
    tejsupra@gmail.com
    Nov 20, 2008
  5. Rushikesh Joshi
    Replies:
    0
    Views:
    355
    Rushikesh Joshi
    Jul 10, 2004
Loading...

Share This Page