N number of Name, address,phone in a file and display in proper format in C Program

#include<stdio.h> #include<conio.h> main() { char name[50]; char address[50]; char telno[50]; FILE *fp; int i,n; fp=fopen("a.dat","a"); printf("How many records:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("\nEnter the name:"); scanf("%s",name); printf("\nEnter the address:"); scanf("%s",address); printf("\nEnter the telphone:"); scanf("%s",telno); fprintf(fp,"\n%s\t%s\t%s",name,address,telno); } fclose(fp); fp=fopen("a.dat","r"); printf("Name\tAddress\t\tTelNo\n"); while(fscanf(fp,"%s%s%s",name,address,telno)!=EOF) { …

Read More........

String Functions in C program

// using strlen length of word eg:wildcat ans: 7 #include<stdio.h> #include<conio.h> #include<string.h> main() { char msg[20]; int len; printf("Input message:"); scanf("%s",msg); { len=strlen(msg); printf("Length of the message=%d",len); } } // using strrev eg: WILDCAT Ans: TACDLIW #include<stdio.h> #include<conio.h> #include<string.h> main() …

Read More........