Sabtu, 27 September 2014

Bahasa C++ Penerapan GOTO Label dan Create and write FILE .txt



#include <iostream>
int main (){
  int n=10;
LP2MARAY:
  cout << n << ", ";
  n--;
  if (n>0) goto LP2MARAY;
  cout << "Mantab .....bahasa C or C++ is The Best!\n";
}
=========================
 
membuat dan Menulis di file .txt 

 
 
 
#include <iostream>
#include <fstream>
using namespace std;

int writeFile();

int main()
{
writeFile
();
}

int writeFile ()
{
ofstream myfile
;
myfile
.open ("example.txt");
myfile
<< "Writing this to a file.\n";
myfile
<< "Writing this to a file.\n";
myfile
<< "Writing this to a file.\n";
myfile
<< "Writing this to a file.\n";
myfile
.close();
return 0;
}
 
Maka pada PATH dimana Installer C++ berada akan terbentuk file baru dengan nama example.txt
 
 
 
 
 

Tidak ada komentar:

Posting Komentar