fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. struct musica2{
  8. char musica[255];
  9. };
  10.  
  11. int main() {
  12. FILE *arquivo;
  13. musica2 *z = new musica2[12];
  14. arquivo = stdin; //arquivo = fopen( "teste.dat", "r" );
  15. int i=0;
  16. if( arquivo == NULL )
  17. cout << "Erro ao abrir arquivo." << endl;
  18. else {
  19. while( !feof( arquivo ) ) {
  20. fgets( z[i++].musica, 255, arquivo );
  21. }
  22. fclose(arquivo);
  23. }
  24. cout << z[3].musica;
  25. return 0;
  26. }
Success #stdin #stdout 0s 3472KB
stdin
vetorZero
vetorUm
vetorDois
vetorTres
vetorQuatro
vetorCinco
stdout
vetorTres