473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

exe runs from BCB IDE and on double-click, won't run from cmd line... help!

Hi there,

I'm working with BCB6, and I'm having a strange error. I've tried
to find a solution elsewhere, but I've got everyone scratching their
heads...

What's happening is that any exe I build in BCB6 that opens another
file will run fine if I run it from the IDE, and will run if I
double-click the exe, but when I try to run it from the command line,
it doesn't find the file specified. That is, I'll get the error code
specified for a file not found.

I've written a simple 'readlines' script to eliminate the possibility
that there's some problem with the more complex scripts I'm trying to
run, and I still have the same problem. (script attached)
The file "haarcascade_frontalface_alt.xml" is in the project folder
with the exe, and I've added that folder to the include path and
library path (not that that's necessary for this script, I think).
Obviously, for this script, I get the "error opening output file" error
message.

Anyone have any ideas what I'm doing wrong? Any and all assistance
would be greatly appreciated.

Cheers, Al.

//Code Starts
//---------------------------------------------------------------------------

#include <fstream>
#include <string>
#include <iostream>
using namespace std;

int main()
{
string str;
ifstream haarfile("haarcascade_frontalface_alt.xml");
if (!haarfile) //test file open
{
cout << "error opening output file" <<endl;
return -1;
}
while (! haarfile.eof()) //loop through lines
{
getline(haarfile, str);
cout << str << endl;
}
haarfile.close();
return 0;
}

//---------------------------------------------------------------------------
//Code ends

Apr 24 '06 #1
2 1937
al*********@gmail.com wrote:
Hi there,

I'm working with BCB6, and I'm having a strange error. I've tried
to find a solution elsewhere, but I've got everyone scratching their
heads...

BCB6?

I think you'd better find a group specific to your environment.

--
Ian Collins.
Apr 24 '06 #2
Sorry, I do not have a solution to your problem, but I did see some
things that should be changed in your code (see below)

al*********@gmail.com wrote:
Hi there,

I'm working with BCB6, and I'm having a strange error. I've tried
to find a solution elsewhere, but I've got everyone scratching their
heads...

What's happening is that any exe I build in BCB6 that opens another
file will run fine if I run it from the IDE, and will run if I
double-click the exe, but when I try to run it from the command line,
it doesn't find the file specified. That is, I'll get the error code
specified for a file not found. [snip]
#include <fstream>
#include <string>
#include <iostream>
using namespace std;

int main()
{
string str;
ifstream haarfile("haarcascade_frontalface_alt.xml");
if (!haarfile) //test file open
{
cout << "error opening output file" <<endl;
return -1;
IIRC the only portable values that main() can return are 0, EXIT_SUCCESS
(usually #defined to be 0), and EXIT_FAILURE. The latter two are
declared in <cstdlib>.
}
while (! haarfile.eof()) //loop through lines
{
getline(haarfile, str);
cout << str << endl;
}
This will loop one too many times. Better is:

while (getline(harrfile, str)) {
cout << str << endl;
}

See http://www.parashift.com/c++-faq-lit....html#faq-15.5 for
more info (and be sure to read the whole FAQ too, there is lots of good
stuff in there).
haarfile.close();
Not strictly necessary as the file will be closed by ifstream's
destructor when haarfile goes out of scope.
return 0;
Also not strictly necessary in C++, though some people like to have it
explicitly there.
}

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Apr 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott | last post by:
Hey everyone! I've been working with python for quite a while and have been able to fix all my problems by searching... except for this one! I have a python script that runs *BEAUTIFULLY* when...
12
by: Sydex | last post by:
When I compile code I get error C2664: 'Integration::qgaus' : cannot convert parameter 1 from 'double (double)' to 'double (__cdecl *)(double)' in this part : double Integration::quad2d(double...
20
by: Anonymous | last post by:
Is there a non-brute force method of doing this? transform() looked likely but had no predefined function object. std::vector<double> src; std::vector<int> dest; ...
10
by: Robert Palma | last post by:
I'm having trouble figuring out how to pass a pointer to a double array (1 dimensional) to a C function. Declaring array as: double xx; Declaring func. int process( double *input ) Calling...
10
by: Bryan Parkoff | last post by:
The guideline says to use %f in printf() function using the keyword float and double. For example float a = 1.2345; double b = 5.166666667; printf("%.2f\n %f\n", a, b);
3
by: BlueTrin | last post by:
I am using a DLL written in C, it uses some pointers on functions, I have defined a wrapper around it in C# which uses some delegates: #region Delegates and Marshalling to call solvopt public...
4
by: robinsand | last post by:
Header File: car.h #if !defined CAR_H #define CAR_H enum TCarType { ctEconomy = 1, ctCompact, ctStandard, ctFullSize, ctMiniVan, ctSUV }; class Car { public: Car();
67
by: lcw1964 | last post by:
This may be in the category of bush-league rudimentary, but I am quite perplexed on this and diligent Googling has not provided me with a clear straight answer--perhaps I don't know how to ask the...
15
by: Pucca | last post by:
I'm getting an error when I tried to use this BerConverter class in my C# code. Even though the Interent doc says that it runs on Win2000 sp4, I just thgouth I'll double check. Does anyone know...
3
by: Oleg Subachev | last post by:
I have played with Parallel Extensions and noticed to my surprise that executable compiled for x64 runs slower than compiled for x86: private static double HeavyMath( int I ) { double D1 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.