2D Arrays

Hello. I am having troubles input filing. Any help would be greatly appreciated. :)

This is what the input file looks like:

12
Ami
Ann
Ben
Dan
Ema
Ira
Guy
Leo
Luc
Meg
Sue
Tom
0 0 0 0 0 0 0 1 0 0 1 0
0 0 0 0 0 0 0 0 1 1 0 0
0 0 0 1 0 0 0 0 1 0 0 0
0 0 1 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0 0 1 0 0
0 1 0 0 0 0 0 0 1 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0

These are my errors I get in my program:

"readData(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, int (*) [12], int&)", referenced from:


_main in main.o


ld: symbol(s) not found for architecture x86_64


clang: error: linker command failed with exit code 1 (use -v to see invocation)



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;


const int MAX_STUDENTS = 80; //Max Number of students
const int col = 12; //Number of students


void readData(string studentName[], int friendList[][col], int &studentSize); //Read data from inputfile



int main()
{
    int studentSize; //Use this to read first number of inputfile
    string studentName[MAX_STUDENTS]; //String array for student's name
    int friendList[MAX_STUDENTS][col]; //2D array for the set of numbers
    
    readData(studentName, friendList, studentSize);
    
    cout << studentSize; //Test to see if input file is correct
    
    
    
    
    return 0;
    
}



void readData(int studentName[], int friendList[][col], int &studentSize)
{
    ifstream inputFile;
    
    inputFile.open("3club.txt");
    if(inputFile.fail())
    {
        cout<< "Input file was unable to open." <<endl;
    }
    
    inputFile >> studentSize;
    
    for(int current = 0; current < studentSize; current++)
    {
        inputFile >> studentName[current];
    }
    
    for(int row = 0; row < studentSize; row++)
    {
        for(int col = 0; col < studentSize; col++)
        {
            inputFile >> friendList[row][col];
        }
    } //End for-loop
}
I dont know what this program does. I do know you passed the wrong type of parameter in function readData, studentName array is type string
I just need help trying to read the data from the specific text file that is listed above the code. The input file "3club.txt" is the input file above the code. I am suppose to read the the studentSize which would be 12 in the first line of the text file. The names are listed into studentName[] and the matrix is stored inside of friendList[].
Topic archived. No new replies allowed.