Advertisement
Guest User

Untitled

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