CC> so could someone write me a exp. program that does the following.
CC> input "Enter Name " , name$
CC> if name$ = "Cyber Con" then print "Hi Cyber Con"
CC> open "file1.fil" as 1
CC> put 1, name$
CC> Close
CC> END
CC> //' next program
CC> open "file1.fil" as 1
CC> get 1, name$
CC> print name$
CC> END
for that kind of thing use Perl instead; C/C++ is better suited for
heavy-duty calculations such as image processing, sound processing,
operating systems, interpreters, ...
in classic C++:
#include
int main () {
cout << "Enter Name ";
char name[80];
cin >> name;
if (strcmp (name, "Cyber Con") == 0) cout << "Hi Cyber Con\n";
ofstream f1("file1.fil");
f1 << name << "\n";
return 0;
}
in Perl:
print "Enter Name "; flush stdout;
$_ = ;
print "Hi $_" if /Cyber Con/;
open F1 ">file1.fil";
print F1 "$_\n";
close F1;
in sh language:
echo Enter Name:
read name
if [ "$name" == "Cyber Con" ]; then echo Hi $name; fi
echo $name > file1.fil
the 2nd part, C++:
int main () {
ifstream f1("file1.fil");
char name[80];
f1 >> name;
cout << name << '\n';
return 0;
}
in Perl:
open F1 "file1.fil";
print scalar();
close F1;
in sh language:
head -1 file1.fil
or assuming there's really only 1 line in that file:
cat file1.fil
matju
--- Terminate 4.00/Pro
---------------
* Origin: The Lost Remains Of SatelliteSoft BBS (1:163/215.42)
|