C program works on W98 but not new WXP machine

D

Denise Mills

Hi,

On my previous Windows 98 machine, I wrote a simple C program that takes
two text files as input, performs some calculations, then produces a
text file that contains the results. It worked fine on that machine.
Recently, however, I obtained a new Windows XP machine, and the program
is not working correctly on my new computer computer. On the new XP
machine, I'm running the program in the DOS window, as before, and the
program does execute and produce an output file, however the file is
empty.


I tried the following, but the results were unchanged:

1. Compiling it on the new machine

2. Changing the location of the input files, and thus the directory
path, so that there were no spaces in the path, i.e., the default path
contained "documents and settings." (The program, itself, is in a
folder that is accessible from any location, and I have used other
programs within this same folder with associated input files in other
locations and it works fine, so that isn't the problem)

3. Logging in as administrator to see if there was a permission problem



The program was created in Borland C++ 5.02.

Any ideas? Is there something obvious that I'm overlooking?

Thanks for your time.

DM
 
S

Sidney Cadot

Denise said:
Hi,

On my previous Windows 98 machine, I wrote a simple C program that takes
two text files as input, performs some calculations, then produces a
text file that contains the results. It worked fine on that machine.
Recently, however, I obtained a new Windows XP machine, and the program
is not working correctly on my new computer computer. On the new XP
machine, I'm running the program in the DOS window, as before, and the
program does execute and produce an output file, however the file is empty.


I tried the following, but the results were unchanged:

1. Compiling it on the new machine

2. Changing the location of the input files, and thus the directory
path, so that there were no spaces in the path, i.e., the default path
contained "documents and settings." (The program, itself, is in a
folder that is accessible from any location, and I have used other
programs within this same folder with associated input files in other
locations and it works fine, so that isn't the problem)

3. Logging in as administrator to see if there was a permission problem



The program was created in Borland C++ 5.02.

Are you sure you use the compiler in C mode?
Any ideas? Is there something obvious that I'm overlooking?

Thanks for your time.

Your program seems to invoke undefined behavior, implementation-defined
behavior, or perhaps you have triggered a compiler bug (unlikely).

Please simplify the program to the smallest version that you'd expect to
work but doesn't. If this contains Windows-specific code, show it in a
windows-dedicated newsgroup. If it is (near-)standard C code, show it
here to have it scrutinized.

Best regards,

Sidney
 
P

Peter Pichler

Denise Mills said:
Hi,

On my previous Windows 98 machine, I wrote a simple C program that takes
two text files as input, performs some calculations, then produces a
text file that contains the results. It worked fine on that machine.
Recently, however, I obtained a new Windows XP machine, and the program
is not working correctly on my new computer computer. On the new XP
machine, I'm running the program in the DOS window, as before, and the
program does execute and produce an output file, however the file is
empty.

The answer is simple. You know that Windows XP is the best thing since
sliced bread, right? And in its infinite wisdom, when the system loads
your program, it recognizes that it had been built with Borland C++ and
makes it misbehave like everything not supplied from Microsoft.

I'm just kidding, of course. Without looking at your source, there is no
other way to tell. Most likely you used void main() or some other instance
of undefined behaviour that "seemed to work" on one (version of) an OS
nut not on another. Share your code with the group and we'll see.

Peter
 
G

gabriel

Denise said:
machine, I'm running the program in the DOS window, as before, and the
program does execute and produce an output file, however the file is
empty.

This is a long shot, but look at your code and make sure you are closing
the file after you're done writing to it. Blank files sometimes means that
output files are not committed to disk (ie, you write to the file, but the
contents remain on cache because the changes have not been committed).

Otherwise, as others have said, post your code.
 
D

Darrell Grainger

Hi,

On my previous Windows 98 machine, I wrote a simple C program that takes
two text files as input, performs some calculations, then produces a
text file that contains the results. It worked fine on that machine.
Recently, however, I obtained a new Windows XP machine, and the program
is not working correctly on my new computer computer. On the new XP
machine, I'm running the program in the DOS window, as before, and the
program does execute and produce an output file, however the file is
empty.

The most likely problem is that your program APPEARED to work on Windows
98. It is not uncommon for new programmers to create programs with
undefined behaviour. Undefined behaviour means that anything can happen.
For example, on Windows 98 the program does what is expected. On Windows
XP it fails to create a file.
I tried the following, but the results were unchanged:

1. Compiling it on the new machine

Highly doubtful this would make a difference.
2. Changing the location of the input files, and thus the directory
path, so that there were no spaces in the path, i.e., the default path
contained "documents and settings." (The program, itself, is in a
folder that is accessible from any location, and I have used other
programs within this same folder with associated input files in other
locations and it works fine, so that isn't the problem)

Good guess. This is a common bug in an application.
3. Logging in as administrator to see if there was a permission problem

Another good guess.
The program was created in Borland C++ 5.02.

Any ideas? Is there something obvious that I'm overlooking?

I'm going to guess that you'll have to look at the code and REALLY
understand what it is doing. Look at the comp.lang.c FAQ to see if there
is anything in there to indicate what you might be doing wrong. The FAQ is
at www.eskimo.com/~scs/C-faq/top.html.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top