Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Executing .cpp files

Status
Not open for further replies.

SomeGuy29

Programmer
Jul 12, 2003
5
0
0
CA
I'm new to Borland C++ Builder 6, and I'm reading a tutorial to get to know it. The tutorial told me to make a new .cpp file, and enter some code. I entered what it said, but now it won't run. I don't get any error messages; it just compiles, then does nothing. It ran the first time I tried, but it won't any more. I didn't change any settings, and I've tried rebooting, reinstalling, everything. Can someon please help me? Thanks.
 
The most of times you need to construct a project
try doing this
in the menu choose new|application
then a form appears, add some components, set their properties and add some code for the events, run the project (pressing F9 is the easiest way).
The code you must addit to the editor (you can access to it presing F12 Key)



---LastCyborg---
 
I can make and run applications with forms; it's running .cpp files that's the problem. I go new | .cpp file, then procede to write the script. I hit run, it compiles, then nothing happens. It's really odd, because the first time I tried, it DID run, but it won't any more.
 
If you have just the cpp file u can run it making a console application, then on the editor change your code for yours, leaving the line where says int main.
I mean
if you have a simple program
#include <some libraries>
void main ()
{
cout &quot;Hello World&quot;
...
...
...
source code
...
etc
}
do this
create a new console application
and in the line

#include <some libraries>
int main (some arguments)
{
cout &quot;Hello World&quot;
...
...
...
source code
...
etc
return something;
}






---LastCyborg---
 
that's exactly what my code is:

#include <stuff>

int main (some arguments) {
cout << &quot;Hello&quot;;
getch();
return 0;
}

and it does nothing. No error messages or anything.
 
I have this code & it runs always I

#include <iostream.h>
#include <conio.h>
#pragma hdrstop
#pragma argsused
int main(int argc, char* argv[])
{
cout << &quot;Hello World&quot;;
getch();
return 0;
}




---LastCyborg---
 
You're right, that should run, but I copied and pasted that exact code into a new .cpp file, and it didn't run. It compiled, but never executed.
 
How exactly are you trying to get the executable to run? Are you building the CPP file only or are you compiling, linking, and running (F9)?


James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
It could be that it actually runs but shuts down the DOS-window (or really: the text-mode window) so fast You never sees it. I know it should wait for a keystroke but with Win i'we seen some quite odd things happen.
Try to compile (Ctrl-F9) and then execute the newly build EXE through some other program like Explorer (i'm using Windows Commander...it's like Norton Commander for windows).
That could do the trick or at least give You some clue to what happens (and not).

Totte
 
Actually, I've tried just that, and it still doesn't do anything. Who knows...
 
Sorry, logged in with the wrong account.
 
Totte,
the windows must appear and stay there until a key is pressed because the code has a getch();



---LastCyborg---
 
you got to add the cpp file to the project.

go to project, and then to &quot;add to project&quot; and select the proper cpp file from the list.

please excuse this if it is not applicable to your situation.

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top