[C++] error: File cannot be found

  • Context: C/C++ 
  • Thread starter Thread starter happysauce
  • Start date Start date
  • Tags Tags
    Error File
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
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 ()
{
count << "Hello World";
count << endl;
count << "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;


count << 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.
 
Physics 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.