Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Why an C program .exe cannot get output

Status
Not open for further replies.

hednast

Newbie level 4
Joined
Aug 3, 2005
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,360
Hello. I have a problem. When I compile in a turbo C compiler I can get the result that I want. But after I compile that project file into an exe and then run that exe, I don't get the results I want anymore. Why is there a difference between the project file and the compiled exe.

Please asists. Thank you.
 

echo47

Advanced Member level 5
Joined
Apr 7, 2002
Messages
3,942
Helped
637
Reputation
1,272
Reaction score
88
Trophy points
1,328
Location
USA
Activity points
33,183
That's not much information to go on.

I would guess that your project file has configuration settings that are different from Turbo C's default project settings.
 

jimjim2k

Advanced Member level 3
Joined
May 17, 2001
Messages
996
Helped
23
Reputation
46
Reaction score
13
Trophy points
1,298
Activity points
7,270
Hi

C has two outputs: stdout and stderr

void fprintf(stdout, "...", ...);
void fprintf(stderr, "...", ...);

in most systems stdout is obviously stderr but in some prohramming styles these tow may differ.

you may check it in linux(unix systems) with something like 2>&1 , ...
you may check it in windows with something like
myprog.exe [myparameter ....] > results.txt

please redo these check and approaches and let us know the status.


tnx
 

hednast

Newbie level 4
Joined
Aug 3, 2005
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,360
Hai.....sorry i am a little confuse with the replies given.........The source code is as below.........



#include <stdio.h>
#include <dos.h>

int main()
{
int i;
unsigned char far* scrn = (unsigned char far*) 0xb0008000;
FILE *fp = fopen("c:\\text.txt","w");

for(i=0;i<6900;i+=2)
fputc(*(scrn+i),fp);

fclose(fp);

return 0;
}

When I press Alt+F9, I get the text.txt with the information on the dos screen. Now I have tested. If I open the dos prompt and straight away type the exe Eg: C:\Scrncap.exe, I won't get the output in the c:\text.txt. The file exist but contains nothing inside. But if I open the turbo C compiler, then close it back again. And then type the exe Eg: C:\scrncap.exe, I get the output of the dos screen in the c:\text.txt. This is the part I really don't understand. Why in a newly open dos prompt I cannot capture the text in the c:\text.txt?

Added after 2 hours 50 minutes:

Hai. Thanks for the helps I receive. I found out my problem. My pc is using Win2K. Therefore I can get the result when I do the compilation in Turbo C compiler. But on the plain dos prompt I cannot get the result. I tested on a Win98 machine and it worked well. Extreme good. Therefore I would conclude that the ancient compiler is not compatible with Win2K onwards.

Problem Solved.
 

hock

Advanced Member level 2
Joined
May 28, 2001
Messages
525
Helped
47
Reputation
94
Reaction score
21
Trophy points
1,298
Location
India
Activity points
3,567
Turbo C can not bypass HAL(hardware Abstrection Layer) used in PC.
you will have to use a windows 2000 compitible compiler and use MFC.
no in out instruction can be used in NT environment.
hock
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top