# include <stdio.h> int main() { char name[50], address[100], phone[20]; FILE *fp; fp = fopen("contacts.txt", "w"); if (fp == NULL) { printf("Error: could not create file.\n"); return 1; } printf("Enter name: "); fgets(name, 50, stdin); printf("Enter address: "); fgets(address, 100, stdin); printf("Enter phone number: "); fgets(phone, 20, stdin); fprintf(fp, "Name: %sAddress: %sPhone: %s", name, address, phone); fclose(fp); printf("File created successfully.\n"); return 0; } 2. Write a c program to add some more records ...
Comments
Post a Comment