Batch Conversion

I am a Beginner in C++ Programming and use SYSTEM() Function
to execute external Programmes from within C++ compiled EXE.

1. How can I handle batch ERRORLEVEL in C++ and Convert the following
Batch codes into C++ ?

[TEST.CMD]
FIND.EXE "str1" "file1"
IF %errorlevel%==0 GOTO "label1"
SET "var1"="text"
GOTO "label2"

:label1
code lines
exit

:label2
code lines
exit


2. How to develop C++ Codes for execution of System Shutdown ?

Can I find some help ?

Thanx in anticipation.

(youngstar)

the system function returns the error level as an int, so
1
2
3
4
5
if (system(...)) {
     // goes here when not 0
} else {
     // goes here when 0
} 


if you include cstdio, you can use the exit() command to exit from any point, just pass it an integer as the parameter for it's error level
Topic archived. No new replies allowed.