Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MailingList
//gcc 7.4.0 //MailingList: write a program that displays menu of a mailing list ,containing enter, search and display functions;reading user input it executes the chosen function; //this code is created by Rezaul Hoque on March 21,2022;contact: jewelmrh@yahoo.com,Dhaka, Bangladesh //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <stdio.h> #include <stdlib.h> #include <string.h> int n=3; struct mail{ char name[30]; char city[30]; int house; int road; int code; }m[3]; void enter(); void search(); void display(); void enter () { printf("\nEnter name,city, house,road and postal code:\n"); for(int k=0; k<n;k++) scanf("%s\t%s\t%d\t%d\t%d\n",m[k].name,m[k].city,&m[k].house,&m[k].road, &m[k].code); } void display(){ int i; printf("name\tcity\thouse\troad\tcode:\n"); for(i=0;i<n;i++){ printf("%s",m[i].name); printf ("\t%s", m[i].city); printf("\t%d",m[i].house); printf("\t%d",m[i].road); printf("\t%d",m[i].code); printf("\n");} } void search(){ char name [80]; printf("name:"); int find=0; scanf("%s",name); for(int i=0; i<n;i++) if(!strcmp(m[i].name,name)){ printf("Item found:\n"); printf("name\tcity\thouse\troad\tcode:\n"); printf("%s",m[i].name); printf ("\t%s", m[i].city); printf("\t%d",m[i].house); printf("\t%d",m[i].road); printf("\t%d",m[i].code); find=1; printf("\n"); } if(!find) printf("Item not found.\n"); } int main(){ int choice; printf(" (1)Enter (2) Search (3) Display (4)Quit\n"); do{ scanf("%d",&choice); switch(choice){ case 1: enter(); break; case 2: search(); break; case 3: display(); break; } }while(choice!=4); return 0; }
run
|
edit
|
history
|
help
0
Spring 2017 Project 2 v1.5
faster posting list using skip pointers
example of scanf and basic integer manipulation
FILE_Access
Stub Program for Problem 6 HW 2
String operations in C (without using built-in methods)
Tern operators
tremendo codigaso ayudantia
REGISTRO EN C
ptr_to_ptr