Error Nullptr was not declared - c++

So the nullptr error doesnt show up when i compile it at school and i think i can fix it with adding a line when i compile it, is there another way to get rid of it, and the other two errors i dont understand why im getting them at all. Can someone explain at least the nullptr error?
main.cpp: In function 'int main()':
error: 'array' was not declared in this scope
error: 'hours' was not declared in this scope
error: 'nullptr' was not declared in this scope
int main()
{
float *studentData;
int numStudents;
int size;
int average = getAverage(*array, *hours);
int median = getMedian(hours);
int mode = getMode(hours);
cout << "How many students were surveyed? ";
cin >> numStudents;
studentData = makeArray(numStudents);
if (studentData == nullptr)
cout << "Error allocating memory.";
else
{
getFBData(studentData, numStudents);
selectionSort(studentData, numStudents);
for (int i = 0; i < numStudents; i++)
cout << *(studentData + i) << endl;
delete[] studentData;
}
getAverage(*array, hours);
printArray(size, hours);
getMedian(*array, hours);
getMode(*array, hours);
cout << "STATISTICS " << endl;
cout << "\n Mean: " << average;
cout << "\n Median: " << median;
cout << "\n Mode: " << mode;
return 0;
}

On this line:
int average = getAverage(*array, *hours);
you refer to array and hours, however you have not declared those things yet. The "school version" of the code must have been different.
Re. the nullptr error: that was added to C++ in 2011. Perhaps the school has up-to-date compilers but you have an older compiler at home. If you change nullptr to 0 it will be fine.

The easiest way to solve this problem is to change nullptr to 0. Though not all the time this works. But it can be a small code solution.
You can also use -std=c++11 parameter while compiling using g++.
So the compiling command in the terminal will be :
g++ "your file" -std=c++11

Related

Getting compilation errors when trying to use pointers for dynamically allocated 2D array

I've recently started learning coding in the C++ language, and am having issues grasping the concept of pointers in C++.
I'm trying to practice dynamic memory allocation but keep running into errors when trying to compile my program.
Here are some struct objects I've created along with some global variables outside of my main function:
// Storing x and y values from file
struct gridSize {
int gridXValue;
int gridYValue;
string toString();
};
string gridSize::toString ()
{
ostringstream oss;
oss << "gridXValue : " << gridXValue << endl;
oss << "gridYValue : " << gridYValue << endl;
return (oss.str());
}
// Storing details for each grid area within
// 2D array struct
struct grid_area {
int x, y;
bool is_occupied;
int city_id;
string city_name;
int cloud, cloud_index, pressure, pressure_index;
char cloudcover_LMH, pressure_LMH;
};
gridSize gridSize; //Global struct object
grid_area *ga = nullptr; //Global pointer variable
Here is what my main function looks like:
int main ()
{
int userChoice;
// Main menu to run constantly until user enters 8
while (userChoice != 8) {
cout << "Welcome to Weather Information Processing System!" << endl;
cout << "-------------------------------------------------" << endl;
cout << endl;
cout << "1)\tRead in and process a configuration file" << endl;
cout << "2)\tDisplay city map" << endl;
cout << "3)\tDisplay cloud coverage map (cloudiness index)" << endl;
cout << "4)\tDisplay cloud coverage map (LMH symbols)" << endl;
cout << "5)\tDisplay atmospheric pressure map (pressure index)" << endl;
cout << "6)\tDisplay atmospheric pressure map (LMH symbols)" << endl;
cout << "7)\tShow weather forecast summary report" << endl;
cout << "8)\tQuit" << endl;
cout << endl;
cout << "Please enter your choice: ";
cin >> userChoice;
cout << endl;
if (userChoice == 1) {
// Process all files
readAFile();
}
}
// Deallocate memory for 2D array
for (int i = 0; i < gridSize.gridXValue + 1; i++)
{
delete[] ga[i];
}
delete[] ga;
return (0);
}
I highly suspect the issue lies in the last few portions of my readAFile function, but am unable to identify the problem. Here's the portion where I suspect the problem lies in readAFile:
// Allocate array memory
ga = new grid_area [gridSize.gridXValue + 1];
for (int i = 0; i < gridSize.gridYValue + 1; i++)
ga[i] = new grid_area[gridSize.gridYValue + 1];
// Putting x and y values into array
for (int x_array = 0; x_array < gridSize.gridXValue + 1; x_array++) {
for (int y_array = 0; y_array < gridSize.gridYValue + 1; y_array++) {
ga[x_array][y_array].x = x_array;
ga[x_array][y_array].y = y_array;
}
}
This is error I'm getting:
csci251_a1.cpp: In function ‘int main()’:
csci251_a1.cpp:110:20: error: type ‘struct grid_area’ argument given to ‘delete’, expected pointer
delete[] ga[i];
^
csci251_a1.cpp: In function ‘void readAFile()’:
csci251_a1.cpp:172:54: error: no match for ‘operator=’ (operand types are ‘grid_area’ and ‘grid_area*’)
ga[i] = new grid_area[gridSize.gridYValue + 1];
^
csci251_a1.cpp:32:8: note: candidate: ‘grid_area& grid_area::operator=(const grid_area&)’
struct grid_area {
^~~~~~~~~
csci251_a1.cpp:32:8: note: no known conversion for argument 1 from ‘grid_area*’ to ‘const grid_area&’
csci251_a1.cpp:32:8: note: candidate: ‘grid_area& grid_area::operator=(grid_area&&)’
csci251_a1.cpp:32:8: note: no known conversion for argument 1 from ‘grid_area*’ to ‘grid_area&&’
csci251_a1.cpp:177:24: error: no match for ‘operator[]’ (operand types are ‘grid_area’ and ‘int’)
ga[x_array][y_array].x = x_array;
^
csci251_a1.cpp:178:24: error: no match for ‘operator[]’ (operand types are ‘grid_area’ and ‘int’)
ga[x_array][y_array].y = y_array;
I really don't understand what I'm doing wrong here...
If needed, I can provide the rest of the readAFile function as well. Any help would be greatly appreciated.
I should have used a point-to-pointer variable instead of a regular pointer variable for a dynamic 2D array.
Instead of:
grid_area *ga = nullptr;
It should be:
grid_area **ga = nullptr;
And,
ga = new grid_area [gridSize.gridXValue + 1];
Should be:
ga = new grid_area *[gridSize.gridXValue + 1];
Admittedly, I probably should have searched up some more actual examples before hastily posting a question. Thanks to every one who responded!

C++ Guessing Game Error

I do not know how to declare "random" in the parentheses for "int main()," and need help. (I am a beginner in C++)
Please take a look at my code, try it out, and please notify me with an answer when you think you know how to solve this problem. It'd mean a lot to me. Thanks! Meanwhile, I will keep trying to solve the problem myself as well.
Note: I am using Code::Blocks if you want to be specific.
The error is on Line 7/9 of my code.
Here is my updated code below:
#include <iostream>
#include <stdlib.h>
#include <conio.h>
using namespace std;
int main()
{
int rn = random() % 21; // generates a random int from 0 to 20
// First output asking the user to guess the number
cout << "Please guess my number :" << endl;
int u;
cin >> u;
while (u != rn) // Calculates the answer that you give
{
// If the user's number is greater than the random number
// the program will let you know it's too large
if (u > rn)
{
cout << "You guessed too big!" << endl;
}
// On the other hand, if the user guesses to small
// the program will tell them that it's too small
else if (u < rn)
{
cout << "You guessed too small!" << endl;
}
// If the user does not get the right number, the program
// will tell the user to guess again
cout << "Please guess again :" << endl;
cin >> u;
}
// If the user guesses the number correctly, the program
// will say that they got it right, and end the program
cout << "You guessed it right!" << endl;
getch();
}
Here's the updated compiler error:
||=== Build: Debug in Guess The Number (compiler: GNU GCC Compiler) ===|
C:\Users\Minecraftship\Documents\CPP Programs From Book\Guess The Number\main.cpp||In function 'int main()':|
C:\Users\Minecraftship\Documents\CPP Programs From Book\Guess The Number\main.cpp|12|
error: 'randomize' was not declared in this scope|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Remove the semicolon near main, the compiler is telling you exactly what the issue is:
int main ();
Should be
int main ()
Your code will also not compile even after fixing this because you have not declared the std namespace. You can put this line at the top for now using namespace std; but it is bad practice. You should declare it manually using the scope resolution operator.
And a number of other issues as already mentioned in the comments above, make sure to read the compiler output thoroughly because it tells you what line is causing the issue.
Your code should look like:
#include <iostream>
#include <stdlib.h>
#include <conio.h>
using namespace std;
int main()
{
int rn = random() % 21; // generates a random int from 0 to 20
// First output asking the user to guess the number
cout << "Please guess my number :" << endl;
int u;
cin >> u;
while (u != rn) // Calculates the answer that you give
{
// If the user's number is greater than the random number
// the program will let you know it's too large
if (u > rn)
{
cout << "You guessed too big!" << endl;
}
// On the other hand, if the user guesses to small
// the program will tell them that it's too small
else if (u < rn)
{
cout << "You guessed too small!" << endl;
}
// If the user does not get the right number, the program
// will tell the user to guess again
cout << "Please guess again :" << endl;
cin >> u;
}
// If the user guesses the number correctly, the program
// will say that they got it right, and end the program
cout << "You guessed it right!" << endl;
getch();
}
Someone else got to it. There are no semicolons after signatures to methods like main().
One other thing not mentioned, I'm guessing you want
while (u != rn)
Also, be careful of the difference in "=" and "==".
BTW -- Welcome to C++!!!
a little more portable version (doesn't use conio.h) which lets the computer play against himself:
#include <iostream>
#include <cstdlib>
#include <ctime>
int get_random_in_range(int min, int max)
{
return std::rand() % (max - min) + min;
}
// returns 0 if user guessed right, negative value if user
// guessed too small, positive if user guessed too big
int check_user_guess(int guess, int my_secret)
{
return guess - my_secret;
}
int main ()
{
int my_guess = get_random_in_range(1, 10);
std::cout << "I think of " << my_guess << std::endl;
std::cout << "Please guess my number: ";
int user_guess = get_random_in_range(1, 10);
std::cout << user_guess << std::endl;
while (check_user_guess(user_guess, my_guess) != 0)
{
std::cout << "You guessed " << user_guess << std::endl;
if (check_user_guess(user_guess, my_guess) > 0)
{
std::cout << "You guessed too big!" << std::endl;
}
else if (check_user_guess(user_guess, my_guess) < 0)
{
std::cout << "You guessed too small!" << std::endl;
}
std::cout << "Please guess again: ";
user_guess = get_random_in_range(1, 10);
std::cout << user_guess << std::endl;
}
std::cout << std::endl << "You guessed it right!";
}
try it here: http://coliru.stacked-crooked.com/a/5bf0b9201ef57529

Reading into an Array Multiple Times

I'm having a little trouble with my code. It's pretty much supposed to open two files, and compare the first twenty line of the file "StudentAnswers.txt" [inputted as a char into a char array] against a char value in (each line of another file) "CorrectAnswers.txt" in another array at the same position (index). It's like a linear search, but the same position in the arrays. Then a report should be displayed, detailing which question the student missed, the given answer, the correct answer, and if the student passed (got >= 70%) or not, like the following:
Report for Student X:
2 (A/D), 3 (C/D), 5(D/A)
This student passed the exam!
Then it should clear the SAArray, and feed the next twenty lines from StudentAnswers.txt, and start the process all over again. I guess the program has to determine the number of students from (lines of 'StudentAnswers.txt' file / 20).
I'm having trouble displaying the report, and having the array clear itself after the program. I'm guessing this can be done with a while loop and an accumulator for the number of students (to be determined by above equation).
Also, Visual Studio seems to go to "Missed __ questions for a total of ___ %", and then keep looping -858993460.
Any help would be appreciated.
#include <iostream>
#include <fstream>
#include <string>
#include <array>
#include <algorithm>
using namespace std;
void GradeReturn(char[], char[], int, int, int);
string PassFail(float);
int main()
{
ifstream SA("StudentAnswers.txt");
ifstream CA("CorrectAnswers.txt");char CAArray[20];
char SAArray[20];
// char SA2Array[20];
bool isCorrect;
int correct;
int incorrect;
int counter;
correct = 0;incorrect = 0;
counter = 0;
cout << endl;
if (!SA.fail())
{
cout << "'StudentAnswers.txt' file opened successfully." << endl;
cout << "'CorrectAnswers.txt' file opened successfully." << endl << endl;
int a = 0;
int b = 0;
while (a < 20)
{
CA >> CAArray[a];
a++;
} // while loop to feed char into the array
while (b < 20)
{
SA >> SAArray[b];
b++;
}
} // while loop to feed char into array
CA.close(); // closing "CorrectAnswers.txt"
SA.close(); // closing "StudentAnswers.txt"
GradeReturn(&CAArray[counter], &SAArray[counter], correct, incorrect, counter);
return 0;
}
void GradeReturn(char CAArray[], char SAArray[], int correct, int incorrect, int counter)
{
float percent;
float hundred;
int student;
int catcher[20];
int writeCatcher; int starter;
int catcher_size;
student = 0;
writeCatcher = 0;
catcher_size = ((sizeof catcher) / 4);
while (counter < 20)
{
if ((CAArray[counter]) == (SAArray[counter]))
{
correct++;
cout << "Good job!" << endl;
} // correct handling
else
{
incorrect++;
cout << "You got question " << counter << " wrong." << endl;
counter >> catcher[writeCatcher];
writeCatcher++;
} // incorrect handling
counter++;
} // while loop to determine if a student got a question right or wrong
static_cast <float> (incorrect); // float conversion
cout << endl; // for cleanliness
percent = ((static_cast <float> (correct)) / 20); // percentage
hundred = percent * 100;
PassFail(percent);
if (PassFail(percent) == "pass")
{
student++;
cout << "Report for Student " << student << ":" << endl;
cout << "-----------------------------" << endl;
cout << "Missed " << incorrect << " questions out of 20 for ";
cout << hundred << " % correct." << endl << endl;
starter = 0;
while (starter < (sizeof catcher)
{
if(1=1)
{
catcher_size
}
else
{
cout << "";
starter++;
}
}
}
else if (PassFail(percent) == "fail")
{
student++;
cout << "Missed " << incorrect << " questions out of 20 for ";
cout << hundred << " % correct." << endl << endl;
while (starter < catcher_size)
{
if ((catcher[starter]) == -858993460)
{
starter++;
}
else
{
cout << "";
starter++;
}
}
}
return;
}
string PassFail(float percent)
{
if (percent >= 0.70) // if <pass>
{
return "pass";
}
else // if <fail>
{
return "fail";
}
cout << endl;
}
To get a loop you should keep streams open instead of closing them after reading 20 lines.
As pseudo code that would be:
a = 0;
while(streams_not_empty)
{
CA >> CAArray[a];
SA >> SAArray[a];
++a;
if (a == 20)
{
GradeReturn(&CAArray[counter], &SAArray[counter], correct, incorrect, counter);
a = 0; // Reset a
}
}
CA.close(); // closing "CorrectAnswers.txt"
SA.close(); // closing "StudentAnswers.txt"
You would also need to pass correct, incorrect, counter by reference so that the GradeReturn can change their value and their by do the accumulation.
Like:
void GradeReturn(char CAArray[], char SAArray[], int& correct, int& incorrect, int& counter)
Further you shouldn't rely on being able to read exactly Nx20 lines from the files every time. A file could have, e.g. 108 (5x20 + 8) lines, so you code should be able to handle the with only 8 lines. In other words, don't hard code 20 in your function like while (counter < 20). Instead pass the number of lines to be handled and do while (counter < number_to_handle).
Something like this as pseudo code:
a = 0;
while(streams_not_empty)
{
CA >> CAArray[a];
SA >> SAArray[a];
++a;
if (a == 20)
{
GradeReturn(&CAArray[counter], &SAArray[counter], correct, incorrect, counter, a);
// ^
a = 0; // Reset a
}
}
if (a != 0)
{
// Process the rest
GradeReturn(&CAArray[counter], &SAArray[counter], correct, incorrect, counter, a);
}
CA.close(); // closing "CorrectAnswers.txt"
SA.close(); // closing "StudentAnswers.txt"
One problem you have is you're trying to compare C-style strings with the == operator. This will compare them essentially as if they were pointers to char, i.e. compare whether they point at the same location in memory, not compare the contents of the string. I urge you to look up array-decay and c-string variables to understand more.
Specifically, if (PassFail(percent) == "pass") isn't going to do what you want it to. strcomp doc, strncmp doc using std::string variables instead of c-style strings would all work, but it would be better simply to compare percent to a value, i.e. if(percent >= 0.70 directly instead of calling PassFail and comparing a string.
There are many other issues here also, you at one point call PassFail but do nothing with the return value. The only side affect of PassFail is cout << endl, if that's what you intend, it's a poor decision and hard to read way to put a newline on the console.
Try asking your compiler for more warnings, that's often helpful in finding these types of issues. -Wall -Wextra work for gcc, you may have to read your compiler manual...

Return Pointers With Multiple Value Win32 Linking Error

I have encountered the typical No Entry Point Personality V0 error before and worked around it with: -fno-exceptions. Although this time when I use the workaround cmd crashed and only runs the first cin >> line of the program.
However, I can run the program no problem in MSYS.
I compiled with:
g++ ReturnPointer.cpp -o ReturnPointer.exe (gave error)
g++ ReturnPointer.cpp -o ReturnPointer.exe -fno-exceptions (runs: MSYS Shell Only)
#include <iostream>
short factor(int, int*, int*);
int main()
{
int number, squared, cubed;
short error;
std::cout << "Enter a number (0 - 20 ): ";
std::cin >> number;
error = factor(number, &squared, &cubed);
if (!error)
{
std::cout << "number: " << number << "\n";
std::cout << "square: " << squared << "\n";
std::cout << "cubed: " << cubed << "\n";
}
else
std::cout << "Error encountered!!\n";
return 0;
}
short factor(int n, int* pSquared, int* pCubed)
{
short value = 0;
if (n > 20)
{
value = 1;
}
else
{
*pSquared = n * n;
*pCubed = n * n * n;
value = 0;
}
return value;
}
Granted, this isn't the end of the world. I am just expanding my knowledge on an area of C++ that trips me up a lot. Although, if I were to ever use pointers in this manner in a larger program...that would turn into a mess.
I would just like to know what needs to be done or what I am missing to run this in CMD.

Errors when linking and compiling C++ files using TextPad/G++, possibly (probably) just syntax?

This very well could be a syntax error on my part since I am rather new with using multiple files and structs in C++ (in particular, passing structs to functions). Here are the three files:
main.cpp:
#include <iostream>
#include <fstream>
#include <string>
#include "common.h"
using namespace std;
void honorStatus(int, student studentList[]);
int main(void)
{
int header;
string filename;
ifstream inputFile;
student studentList[MAX_STUDENTS];
// Get filename from user and try to open file
cout << "Please enter a filename: ";
cin >> filename;
inputFile.open(filename.c_str());
// If file cannot be opened, output error message and close program
if (inputFile.fail())
{
cout << "Input file could not be opened. Please try again." << endl;
return 1;
}
// Get header number from file. If header is larger than max number
// of students, error is output and program is closed
inputFile >> header;
if (header > MAX_STUDENTS)
{
cout << "Number of students has exceeded maximum of " << MAX_STUDENTS
<< ". Please try again." << endl;
return 1;
}
// Read file information (student ID, hours, and GPA) into struct array
for (int i = 0; i < header; i++)
{
inputFile >> studentList[i].ID >> studentList[i].hours >> studentList[i].GPA;
}
// Close the file
inputFile.close();
// Calls function honorStatus
honorStatus(header, studentList);
return 0;
}
functs.cpp:
#include <iostream>
#include "common.h"
using namespace std;
// Function to determine classification and honors society eligibility requirements
// of each student, outputting this information and the number of students eligible
void honorStatus(int fheader, student fstudentList[])
{
int cnt = 0;
for (int i = 0; i < fheader; i++)
{
if (fstudentList[i].hours < 30)
{
cout << "Student #" << fstudentList[i].ID << " is a freshman with GPA of "
<< fstudentList[i].GPA << ". Not eligible." << endl;
}
else if (fstudentList[i].hours > 29 && fstudentList[i].hours < 60)
{
if (fstudentList[i].GPA >= 3.75)
{
cout << "Student #" << fstudentList[i].ID << " is a sophomore with GPA of "
<< fstudentList[i].GPA << ". Eligible." << endl;
cnt++;
}
else
{
cout << "Student #" << fstudentList[i].ID << " is a sophomore with GPA of "
<< fstudentList[i].GPA << ". Not Eligible." << endl;
}
}
else if (fstudentList[i].hours > 59 && fstudentList[i].hours < 90)
{
if (fstudentList[i].GPA >= 3.5)
{
cout << "Student #" << fstudentList[i].ID << " is a junior with GPA of "
<< fstudentList[i].GPA << ". Eligible." << endl;
cnt++;
}
else
{
cout << "Student #" << fstudentList[i].ID << " is a junior with GPA of "
<< fstudentList[i].GPA << ". Not eligible." << endl;
}
}
else
{
if (fstudentList[i].GPA >= 3.25)
{
cout << "Student #" << fstudentList[i].ID << " is a senior with GPA of "
<< fstudentList[i].GPA << ". Eligible." << endl;
cnt++;
}
else
{
cout << "Student #" << fstudentList[i].ID << " is a senior with GPA of "
<< fstudentList[i].GPA << ". Not eligible." << endl;
}
}
}
cout << "\nTotal number of students eligible for the Honor Society is " << cnt << "." << endl;
}
common.h:
// Maximum number of students allowed
const int MAX_STUDENTS = 10;
// Struct for student info
struct student
{
int ID;
int hours;
float GPA;
};
When using TextPad/G++, I get the following error:
/cygdrive/c/Users/Korina/AppData/Local/Temp/ccxq9DAh.o:p7b.cpp:(.text+0x0): multiple definition of `main'
/cygdrive/c/Users/Korina/AppData/Local/Temp/ccmtzOP2.o:p5.cpp:(.text+0x0): first defined here
/cygdrive/c/Users/Korina/AppData/Local/Temp/ccLa96oD.o:test.cpp:(.text+0x0): multiple definition of `main'
/cygdrive/c/Users/Korina/AppData/Local/Temp/ccmtzOP2.o:p5.cpp:(.text+0x0): first defined here
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld: /cygdrive/c/Users/Korina/AppData/Local/Temp/ccmtzOP2.o: bad reloc address 0x1b in section `.text$_ZNSt11char_traitsIcE7compareEPKcS2_j[__ZNSt11char_traitsIcE7compareEPKcS2_j]'
collect2: error: ld returned 1 exit status
When using an online C++ compiler (CompileOnline), I get:
/tmp/ccIMwHEt.o: In function `main':
main.cpp:(.text+0x1cf): undefined reference to `honorStatus(int, student*)'
collect2: error: ld returned 1 exit status
I wasn't able to find a guide on how to set up TextPad/G++ to compile and link multiple files, but my instructor gave a short set of instructions that I followed. Here is how it's set up:
So this could a two-parter question (how do I set up TextPad to correctly compile/link files? why is my honorStatus() function undefined in main.cpp?) or it could just be that my syntax is wrong. I'm honestly not sure. Sorry if this is a bit long; I wanted to include as much detail as possible. Any help is greatly appreciated.
The problem is that you are compiling "*.cpp" all together. Given this
/cygdrive/c/Users/Korina/AppData/Local/Temp/ccxq9DAh.o:p7b.cpp:(.text+0x0): multiple definition of `main'
/cygdrive/c/Users/Korina/AppData/Local/Temp/ccmtzOP2.o:p5.cpp:(.text+0x0): first defined here
/cygdrive/c/Users/Korina/AppData/Local/Temp/ccLa96oD.o:test.cpp:(.text+0x0): multiple definition of `main'
/cygdrive/c/Users/Korina/AppData/Local/Temp/ccmtzOP2.o:p5.cpp:(.text+0x0): first defined here
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld: /cygdrive/c/Users/Korina/AppData/Local/Temp/ccmtzOP2.o: bad reloc address 0x1b in section `.text$_ZNSt11char_traitsIcE7compareEPKcS2_j[__ZNSt11char_traitsIcE7compareEPKcS2_j]'
collect2: error: ld returned 1 exit status
we can see that the the compiler has been trying to combine p5.cpp, p7b.cpp and test.cpp into one executable (possibly other .cpp files too).
You need to actually tell the compiler exactly which files you want to build together to one program. E.g.
g++ main.cpp functs.cpp -o main.exe
(I would suggest also adding -Wall -Wextra -Werror to the compile line, as that allows the compiler to detect the small mistakes that aren't strictly errors, but where you probably got something wrong)
From the linker output you can see that main function is found in these files: p7b.cpp, p5.cpp and test.cpp. As there's no main.cpp file listed in the linker output, I guess that current directory is setup to be where p7b.cpp and other files are located.
Try to change Initial Folder to be where your main.cpp file is set (something like /cygdrive/c/Users/Korina/programming/). Also, remove all unrelevant files from that directory, as you're compiling all cpp files.
The error message is clear enough. Your project contains the following files
p7b.cpp, p5.cpp, test.cpp
where in each file there is defined function main. Put a place in order with your project files.
As for the error message when you use the inline compiler then it seems module functs.cpp is not included in the project. So the compiler does not see the function definition.