C/C++ [C++] error: File cannot be found

  • Thread starter Thread starter happysauce
  • Start date Start date
  • Tags Tags
    Error File
AI Thread Summary
The discussion revolves around a user learning C++ with Visual Studio 2010 and encountering issues while compiling programs. Initially, the user successfully created a simple "Hello World" program but faced an error when trying to run a second program that involved variables. The error indicated that the executable file could not be found. This was identified as a potential issue stemming from having two main() functions across different source files within the same project, which leads to linking errors. To resolve this, the user created separate projects for each program. The conversation also clarified that while a project must contain one main() function as the entry point, it is permissible to define multiple other functions within the same project, regardless of their names.
happysauce
Messages
42
Reaction score
0
So I just started teaching myself C++ using visual studio 2010. I started with a nice easy program.

First thing I did was created a new project called "Tutorial." Under source files I right clicked and selected add -> new item, I named it Introduction.cpp. I created this:

#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World";
cout << endl;
cout << "My name is Neil";

system("pause");
return 0;
}



Worked out fine. It compiled and ran properly.

So I added another item and named it variables.cpp and made this:

#include <iostream>
using namespace std;

int main ()
{
int a, b, c;
int sum;


a=1;
b=2;
c=3;
a=a+4;
sum = a+b+c;


cout << sum;
system("pause");
return 0;

}

This time when I compile and run I get an error Unable to start program "Tutorials/Debug/Tutorial.exe the system in the file cannot be found.

So I go back and try the other program and i get the same error. A lot of people online say to check the Debug file and look for it, but I didn't find any. I did find tutorial.exe.imbed.manifest though. I don't really know what's going on or how to fix this.
 
Technology news on Phys.org


Are you building a project with two main() functions? That should result in a linking error.
 


Ah that makes sense. I actually fixed it by just making another project with variables instead. So now I have a projected name introduction and a project named variables. My question now is, can I have two different codes in a project using no main function, like name one of them function_one () and the other function_two () (or even main)?
 


happysauce said:
My question now is, can I have two different codes in a project using no main function, like name one of them function_one () and the other function_two () (or even main)?

Your source must contain one main() function. This is the program's entry point. What you name other functions in the same source file or in different source files in the same project is up to you.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Back
Top