| View previous topic :: View next topic |
| Author |
Message |
EBODude Expert Cheater
Reputation: 0
Joined: 18 Oct 2007 Posts: 136
|
Posted: Thu Dec 18, 2008 10:19 pm Post subject: Why Won't This Compile D: |
|
|
Before I get flamed for asking a noob question or not knowing what the hell I'm doing, I want to say this is my first day trying to code C++ and I'm following a tutorial.
I'm using Visual C++ 2008 Express Edition, and this is what I'm trying to compile, or build:
| Code: | // This is a comment
// This program will accept numbers and display their sum
#include <iostream.h>
void main()
{
// define variables
float num1;
float num2;
float total;
// Enter data for the variables
cout << "Enter a value for the first variable: ";
cin >> num1;
cout << "Enter a value for the second variable: ";
cin >> num2;
// Add the two numbers together
total = num1 + num2;
// Display the result
cout << "The sum of the numbers = " << total
} |
My compile error is:
| Code: | 1>------ Build started: Project: Cpp1, Configuration: Debug Win32 ------
1>Embedding manifest...
1>mt.exe : general error c10100b1: Failed to load file "..\Debug\Cpp1.exe". The system cannot find the path specified.
1>Build log was saved at "file://c:\Documents and Settings\Krzysiu\My Documents\Visual Studio 2008\Projects\Cpp1\Cpp1\Debug\BuildLog.htm"
1>Cpp1 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
Can anyone help me out? Google doesn't really help.
|
|
| Back to top |
|
 |
AlbanainRetard Master Cheater
Reputation: 0
Joined: 02 Nov 2008 Posts: 494 Location: Canada eh?
|
Posted: Thu Dec 18, 2008 10:36 pm Post subject: |
|
|
Maybe file is running, or is protected.
also add return 0; at end of main.
_________________
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Dec 18, 2008 10:39 pm Post subject: |
|
|
| AlbanainRetard wrote: | Maybe file is running, or is protected.
also add return 0; at end of main. |
why would he add return 0; when main is type void.
_________________
|
|
| Back to top |
|
 |
EBODude Expert Cheater
Reputation: 0
Joined: 18 Oct 2007 Posts: 136
|
Posted: Thu Dec 18, 2008 11:05 pm Post subject: |
|
|
| AlbanainRetard wrote: | Maybe file is running, or is protected.
also add return 0; at end of main. |
What do you mean? Visual C++ 2008 Express Edition is running, but it won't compile. What do you mean the file is protected?
|
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Thu Dec 18, 2008 11:08 pm Post subject: |
|
|
I don't think you've added the source file to your project correctly. If you were to create an empty project and build it, you will receive the same error. This would happen if you've created your source file using File -> New without adding it to the project.
On your left you should see the project name with 3 folders below (header, resource & source files), right click the source files folder -> add -> new item / or add your existing cpp file to the project.
Last edited by sloppy on Thu Dec 18, 2008 11:09 pm; edited 1 time in total |
|
| Back to top |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Thu Dec 18, 2008 11:08 pm Post subject: |
|
|
| you dont need a return 0. Void means that the coder doesnt care about the return value. Anywho, EBO, close your Compiler, rerun, rebuild
|
|
| Back to top |
|
 |
nog_lorp Grandmaster Cheater
Reputation: 0
Joined: 26 Feb 2006 Posts: 743
|
Posted: Fri Dec 19, 2008 1:11 am Post subject: |
|
|
His program isn't going to link because there is no int main. Change "void main" to "int main". Also, add a return 0 - it won't solve the problem (with no return, it will compile and leave eax as is, which will give it some random return value) but it is a good idea.
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish |
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Fri Dec 19, 2008 4:20 am Post subject: |
|
|
// Display the result
cout << "The sum of the numbers = " << total;
return 0;
}
|
|
| Back to top |
|
 |
EBODude Expert Cheater
Reputation: 0
Joined: 18 Oct 2007 Posts: 136
|
Posted: Fri Dec 19, 2008 10:01 am Post subject: |
|
|
I make a project called Demo1 as a Empty Project.
Then I make a new file, put the code in, then save it as Demo1.
I press Build, then Build Demo1.
And I get that error over and over. And it's not a coding error, I just don't think I'm creating the workspace or whatever you want to call it the right way.
|
|
| Back to top |
|
 |
ups2000ups I post too much
Reputation: 0
Joined: 31 Jul 2006 Posts: 2471
|
Posted: Fri Dec 19, 2008 10:07 am Post subject: |
|
|
| blankrider wrote: | | AlbanainRetard wrote: | Maybe file is running, or is protected.
also add return 0; at end of main. |
why would he add return 0; when main is type void. |
and slippppppppp
using "void main" which should be "int main" is the main function in c++
void int isent allowed in some c++ compilers and some big company's so it is incorrect
the main function should always look like this
int main() {return X;}
ontopic
delete the "debug" folder and try compile it again
if you cant delete it restart your computer and try again (press rebuild all)
_________________
dont complain about my english...
1*1 = 2? |
|
| Back to top |
|
 |
EBODude Expert Cheater
Reputation: 0
Joined: 18 Oct 2007 Posts: 136
|
Posted: Fri Dec 19, 2008 10:23 am Post subject: |
|
|
| ups2000ups wrote: | | blankrider wrote: | | AlbanainRetard wrote: | Maybe file is running, or is protected.
also add return 0; at end of main. |
why would he add return 0; when main is type void. |
ontopic
delete the "debug" folder and try compile it again
if you cant delete it restart your computer and try again (press rebuild all) |
Doesn't do anything. I get the same error.
|
|
| Back to top |
|
 |
ups2000ups I post too much
Reputation: 0
Joined: 31 Jul 2006 Posts: 2471
|
Posted: Fri Dec 19, 2008 10:30 am Post subject: |
|
|
| EBODude wrote: | | ups2000ups wrote: | | blankrider wrote: | | AlbanainRetard wrote: | Maybe file is running, or is protected.
also add return 0; at end of main. |
why would he add return 0; when main is type void. |
ontopic
delete the "debug" folder and try compile it again
if you cant delete it restart your computer and try again (press rebuild all) |
Doesn't do anything. I get the same error. |
ok weird i mean it should be able to find the file it just created
it look like it is protected or already running or something idk really
well you could try this too
go to C:\windows\prefetch and delete everything in it
then try to compile your file again
idk why but thats a common problem for me and some other i know (happening often when you try to inject some dll into something and application crashes)
_________________
dont complain about my english...
1*1 = 2? |
|
| Back to top |
|
 |
EBODude Expert Cheater
Reputation: 0
Joined: 18 Oct 2007 Posts: 136
|
Posted: Fri Dec 19, 2008 10:35 am Post subject: |
|
|
So there's no fix?
Would another IDE fix it? The tutorial I'm following is using Visual C++ 6.
What's the 'best' for newbies out there?
EDIT: Forgot to say, after I deleted everything in the prefetch folder, it still didn't work.
|
|
| Back to top |
|
 |
ups2000ups I post too much
Reputation: 0
Joined: 31 Jul 2006 Posts: 2471
|
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Fri Dec 19, 2008 12:18 pm Post subject: |
|
|
| EBODude wrote: | I make a project called Demo1 as a Empty Project.
Then I make a new file, put the code in, then save it as Demo1.
I press Build, then Build Demo1.
And I get that error over and over. And it's not a coding error, I just don't think I'm creating the workspace or whatever you want to call it the right way. |
After you've made an empty project, how are you creating the new source file? Can you upload a screenshot of the IDE with your project open or upload the project itself?
|
|
| Back to top |
|
 |
|