O
O
olkhovich2019-11-05 23:19:29
C++ / C#
olkhovich, 2019-11-05 23:19:29

Why doesn't the Xcode project see the features described in another file?

A simple program with array input and output functions that are in another file.
Created a command line tool project with main.cpp and added scan_print_arr.cpp to
main.cpp

#include <iostream>
#include "scan_print_arr.hpp"

#define C 17
#define A 35

int main()

{
    
    int arr[A];
    int arr1[C];
    scan_arr(arr, A);
    print_arr(arr, A);
    scan_arr(arr1, C);
    print_arr(arr1, C);
    return 0;
}

scan_print_arr.cpp:
#include "scan_print_arr.hpp"
#include <iostream>

void scan_arr(int arr[], int size) {
    for (int i = 0; i < size; i++) {
        std::cout << "arr[" << i + 1 << "] = ";
        std::cin >> arr[i];
    }
    std::cout << std::endl;
}

void print_arr(int arr[], int size) {
    for (int i = 0; i < size; i++) {
        std::cout << "arr[" << i + 1 << "] = " << arr[i]
        << std::endl;
    }
    std::cout << std::endl;
}

Mistake:
Use of undeclared identifier 'scan_arr'
Use of undeclared identifier 'print_arr'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vanyamba-electronics, 2019-11-06
@olkhovich

In scan_print_arr.hpp add

void scan_arr(int arr[], int size);
void print_arr(int arr[], int size);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question