Advertisement
banovski

Name to file

Jan 26th, 2022
779
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Write a program that asks for the user’s name and saves that
  2. information to disk. Call the program YOURNAME.C and have it save the
  3. user’s name in a file named YOURNAME.TXT. */
  4.  
  5. #include <stdio.h>
  6.  
  7. int main()
  8. {
  9.      char name[22];
  10.      puts("Enter your name (not more than 20 characters): ");
  11.      fgets(name, 21, stdin);
  12.      FILE *out;
  13.      out = fopen("yourname.txt", "w");
  14.      fprintf(out, "%s", name);
  15.      return(0);
  16. }
  17.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement