Why won't visual studio let me run my program?

C++ noob here. I have searched everywhere for this and found many who had the same problem, but no solutions. What am I doing wrong? I am pulling my hair out!

I have built it and it has no errors. However, when I try to debug it with F5 or ctrl + F5 I get the same error:

"Unable to start program 'c:\users\windows\documents\visual studio 2013\Projects\Project1\Debug\Project1.ex...

The system cannot find the file specified"

Obviously this file does not exist, and I have no idea how to make it exist. Again, I have tried EVERYTHING. Please help!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  //getinfo.cpp -- input and output
#include <iostream>

int main()
{
using namespace std;

int carrots;

cout << " How many carrots do you have?" << endl;
cin >> carrots;
cout << "Here are two more. ";
carrots = carrots + 2;
// the next line concatenates output
cout << "Now you have " << carrots << " carrots. " << endl;
return 0;
}
I guess it's problem with your visual studio(either it creates a file in other directory then it tries to find it, or it doesn't create file at all).
closed account (j3Rz8vqX)
Hmm, how new are you?

Did you forget to build it first by any chance?

Maybe you forgot to create/open a project first.

Check the location and see if Project1.exe exists.

c:\users\windows\documents\visual studio 2013\Projects\Project1\Debug\Project1.exe

Although you may not be able to run, can you build it?
Hmmmm im a bit of noob too but have you tried to include stdafx.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  //getinfo.cpp -- input and output
#include "stdafx.h"
#include <iostream>

int main()
{
using namespace std;

int carrots;

cout << " How many carrots do you have?" << endl;
cin >> carrots;
cout << "Here are two more. ";
carrots = carrots + 2;
// the next line concatenates output
cout << "Now you have " << carrots << " carrots. " << endl;
return 0;
}
Looks fine to me , and you don't need to include stdafx.h, try to download another compiler , also put this before the return statement so the program won't close after the cin>>carrots; statement

cin.get();
cin.get();
If Visual Studio doesn't work out for you, then get this:
http://sourceforge.net/projects/codeblocks/files/Binaries/12.11/Windows/codeblocks-12.11mingw-setup_user.exe

It is an IDE with a compiler and debugger (MinGW version 4.7.1).
Topic archived. No new replies allowed.