Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4. #include <fstream>
  5. using namespace std;
  6. int oct2dec (string osemkowa)
  7. {
  8. int dziesietna = strtol(osemkowa.c_str(), NULL, 8);
  9. return dziesietna;
  10. }
  11. int main()
  12. {
  13. string liczba;
  14. fstream plik;
  15. ofstream plik1;
  16. plik1.open("a.txt");
  17. plik.open("b.txt", ios::in);
  18. if(plik.good())
  19. while(!plik.eof())
  20. {
  21. plik>>liczba;
  22. cout<<liczba;
  23. cout<<endl;
  24. cout << "Liczba dziesiętna to : "<< oct2dec(liczba) << endl;
  25. plik1<<oct2dec(liczba)<< " ";
  26. }
  27. plik.close();
  28. system ("pause >nul");
  29. plik1.close();
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement