+ 2
How is the bug of repeated main in a cpp code fixed ?
I have two files in the same project directory and I keep on getting this error say that permission denied and the project directory has a red like bug on it.. I am using eclipse ide..
6 Answers
+ 6
The main function specifies the entry point of program execution. You're not supposed to have two main functions. You can post your code here, it'll help to resolve your problems.
+ 6
Yeah, so, you obviously can't have two files both containing main and in the same scope. What you can do is to place one of the contents of main into a function, and call it in main.
file 1
#include <iostream>
#include "file2.cpp" // whatever the filename is
using namespace std;
int main()
{
cout << "Hello World.";
func();
}
file 2
#pragma once
#include <iostream>
using namespace std;
void func()
{
cout << "Something.";
}
+ 5
Post them all, I guess. Can't debug if there's no code.
+ 2
they are two files
+ 2
first file
#include <iostream>
using namespace std;
into main(){
cout <<"hello world!";
return 0;
}
second file
#include <iostream>
using namespace std;
int main(){
cout <<"I am getting high and guy";
}
yeah.. basically.. this is what I a having...
+ 2
so if I've more than 2 files, I should call them in the main file??
also. #pragma once, what does it mean