Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #define _CRT_SECURE_NO_DEPRECATE
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. FILE *fp;
  8. fp = fopen("C:\\myfiles\\sample3.txt", "w");
  9. // Check permission if you can write a file
  10.  
  11. if(!fp)
  12. {
  13. cout << "Cannot open file.\n";
  14. system("pause");
  15. exit(1);
  16. fputc('\n', fp);
  17. }
  18.  
  19. //Prints the Character ASCII value from 97 to 122 (a-z) to a file
  20. for (int i = 65;i<91;i++)
  21. fputc(i, fp);
  22. fputc('\n', fp);
  23. for (int i = 90; i >64; i--)
  24. fputc(i, fp);
  25. fputc('\n', fp);
  26. for (int i = 97; i < 123; i++)
  27. fputc(i, fp);
  28. fputc('\n', fp);
  29. for (int i = 97; i < 107; i++)
  30. fputc(i, fp);
  31.  
  32. fclose(fp);
  33. system("pause>0");
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement