Click here to Skip to main content
15,886,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<process.h>

void main()
{
     
     system("f:\\C.BAT"); //open a batch file from F drive
     
     getch();
 }



Output- only blank screen come

Anybody give solution why file is not open. when I run the through CMD prompt. It is working. But through TC compiler using c code not working.
Posted
Updated 12-Aug-13 21:28pm
v3
Comments
Fredrik Bornander 13-Aug-13 3:08am    
What is the return value of the system call?
Richard MacCutchan 13-Aug-13 3:29am    
What is the content of the batch file? BTW, that file will run in its own command window which will close as soon as the batch file completes.
sunnyvector 13-Aug-13 5:12am    
The return value of system call is zero.
The content of the batch file is---

@echo off
f:
Z_0100.EXE
@echo on
Richard MacCutchan 13-Aug-13 5:49am    
OK, and what exactly does Z_0100.EXE do?
sunnyvector 14-Aug-13 0:39am    
Z_0100.EXE,this file is written in C code. it works as an application. I want to use this file in
another file. So I run this file as command in c code using system call function. On success return value of system is zero correct but output is not coming on screen. Give me the solution of this problem.

1 solution

As others already pointed out you should:
  • check system call return value.
  • check if the batch file actually was executed (you may have missed its execution, because the window quickly disappears).


It is worth nothing that Turbo C is an ancient compiler and there are far better (free) alternatives, like, for instance Visual Studio Express Edition (the latter featuring a superb debugger).
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900