Clark S. Cox III wrote:
On 2005-07-21 20:17:43 -0400, Baloff <vd****@bi.edu.gr> said:
I only took this code from Thinking in C++ Vol-1 and it did not
compile because of this error. I noticed this line "system(char(26))"
in more than one code in the few 3 chapters of the book. and since it
is a book with some good reputation, I did not think it would be
incorrect. but it looks I have to do some homework.
Are you sure about that? I'm looking at the PDF version of the book
right now, and can't find that text anywhere. In fact, the only
reference to the system() function that I can find in any sample code is
on page 108:
//: C02:CallHello.cpp
// Call another program
#include <cstdlib> // Declare "system()"
using namespace std;
int main() {
system("Hello");
} ///:~
a while back I downloaded the book, I have now a directory with the
source codes, in the files for chapter 3, I could find these 2 programs.
//////////////////////////////////////////////////
//: C02:CallHello.cpp
// From Thinking in C++, 2nd Edition
// Available at
http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
// Call another program
#include <cstdlib> // Declare "system()"
#include <iostream>
using namespace std;
int main() {
system("date");
cin.sync(); cin.get(); return 0;
} ///:~
///////////////////////////////////////////////////
//: C03:Ifthen.cpp
// From Thinking in C++, 2nd Edition
// Available at
http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
// Demonstration of if and if-else conditionals
#include <iostream>
using namespace std;
int main() {
int i;
cout << "type a number and 'Enter'" << endl;
cin >> i;
if(i > 5)
cout << "It's greater than 5" << endl;
else
if(i < 5)
cout << "It's less than 5 " << endl;
else
cout << "It's equal to 5 " << endl;
cout << "type a number and 'Enter'" << endl;
cin >> i;
if(i < 10)
if(i > 5) // "if" is just another statement
cout << "5 < i < 10" << endl;
else
cout << "i <= 5" << endl;
else // Matches "if(i < 10)"
cout << "i >= 10" << endl;
system( char(26)); //<-- this line is not in the book but in the
source code bundled with the book according to the content of the file
in the folder, "assuming I did not modify it some time ago and forgot".
} ///:~
///////////////////////////////////////////////////////