Review the structure type address_t described in
Programming Project 5 of Chapter 10. Write a program that will
create a binary file of address_t structures by repeatedly
prompting the user to enter the IP(internet protocol) address and
nickname and writing the address_t structure to the binary file.
Create a second program that reads each address_t structure from
the binary file and displays it in a readable format on the
screen.//////////Here is problem 5 but the part in bold is
what needs to be solved///////////// Programming Project 5:
Numeric addresses for computers on the international network
Internet are composed of four parts, separated by periods, of the
form:
xx.yy.zz.mm
where xx, yy, zz, and mm are positive integers. Locally, computers
are usually known by a nickname as well. You are designing a
program to process a list of Internet addresses, identifying all
pairs of computers from the same locality. Create a structure type
called address_t with components for the four integers of an
Internet address and a fifth component in which to store an
associated nickname of 10 characters. Your program should read a
list of up to 100 addresses and nicknames terminated by a sentinel
address of all zeros and a sentinel nickname.
SAMPLE DATA:
111.22.3.44 platte
555.66.7.88 wabash
111.22.5.66 green
0.0.0.0 none
The program should display a list of messages identifying each pair
of computers from the same locality---that is, each pair of
computers with matching values in the first two components of the
address. In the messages, the computers should be identified by
their nicknames.
#include<stdio.h>
#include<conio.h>
struct address_t {
int part1;
int part2;
int part3;
int part4;
char nickname[11]; //10 plus 1 for null
}address[15];
void scan_address(char[],struct address_t[],int );
void print_address(struct address_t);
int getnum(int*,char[],char);
int local_address(struct address_t,struct address_t);
int main()
{FILE *input;
char buffer[30],filename[15];
int i=0,j,k;
printf("what is the name of the file you are using? ");
scanf("%s",&filename);
input = fopen(filename,"r");
if(input == NULL)
{ printf("Error opening input file!\n");
return 0;
}
printf("\nThe addresses are\naddress\t\tnickname\n");
for(i=0;;i++)
{fscanf(input,"%s",&buffer);
scan_address(buffer,address,i);
if(address[i].part1==0&&address[i].part2==0&&address[i].part3==0
&&address[i].part4==0)
break;
fscanf(input,"%s",&address[i].nickname);
print_address(address[i]);
}
fclose(input);
printf("\n");
for(j=0;j<i-1;j++)
for(k=j+1;k<i;k++)
if(local_address(address[j],address[k])==1)
printf("Machines %s and %s are on the same local network\n",
address[j].nickname,address[k].nickname);
getch();
return 0;
}
int local_address(struct address_t a,struct address_t b)
{if(a.part2==b.part2)
return 1;
else return 0;
}
int getnum(int *i,char b[],char c)
{int val=0,j;
while(b[*i]!=c)
{val=val*10+(b[*i]-'0');
*i=*i+1;
}
*i=*i+1;
return val;
}
void scan_address(char b[],struct address_t a[],int n)
{int i=0,val;
a[n].part1=getnum(&i,b,'.');
a[n].part2=getnum(&i,b,'.');
a[n].part3=getnum(&i,b,'.');
a[n].part4=getnum(&i,b,'\0');
}
void print_address(struct address_t address)
{printf("%d.%d.%d.%d\t%s\n",address.part1,address.part2,address.part3,
address.part4,address.nickname);
}
Review the structure type address_t described in Programming Project 5 of Chapter 10. Write a program...
USING RAPTOR For the following Programming Challenges, use the modular approach and pseudocode to design a suitable program to solve it. Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. The output should be a list of email addresses where the address is of the following from: first.last@mycollege.edu
Project Lists and Object-oriented Programming Note: using c++ This project is an individual assignment that focuses on object-oriented programming and lists. The list will be a doubly-linked list and it will be implemented using nodes and pointers. The data contained in the list will be objects from a class. Project data: You will choose one of the following classes to define: Boat, Earthquake, Game, Sport, State, Website, House, Phone, Activist, Plant, Fish, Parrot, and Course. Your class code will include...
Your mission in this programming assignment is to create a Python program that will take an input file, determine if the contents of the file contain email addresses and/or phone numbers, create an output file with any found email addresses and phone numbers, and then create an archive with the output file as its contents. Tasks Your program is to accomplish the following: ‐ Welcome the user to the program ‐ Prompt for and get an input filename, a .txt...
All commands must be in the command line. The expense data file is separate. Programming Project #2: Manage Spending Using Commands Objectives: • Understand how to create and manipulate list of objects using array or vector class • Handle input errors and invalid values • Design and create a well-structure program using C++ basic programming constructs and classes. Description: Each “expense” contains 2 values: the spending amount (double) and its description (string) Here is an example of the “expense” data...
C++ Programming question
Problem: 5. Write a program that reads in a list of integers into an array with base type int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input, the program should request a file name. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is to be...
The second programming project involves writing a program that accepts an arithmetic xpression of unsigned integers in postfix notation and builds the arithmetic expression tree that epresents that expression. From that tree, the corresponding fully parenthesized infix expression should be displayed and a file should be generated that contains the three address format instructions. This topic is discussed in the week 4 reading in module 2, section II-B. The main class should create the GUI shown below Three Adddress Generator...
project-8c Write a class named Employee that has data members for an employee's name, ID_number, salary, and email_address (you must use those names - don't make them private). Write a function named make_employee_dict that takes as parameters a list of names, a list of ID numbers, a list of salaries and a list of email addresses (which are all the same length). The function should take the first value of each list and use them to create an Employee object....
Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required. Project Requirements Develop a text...
Quick C Programming Questions: I) Which of the following is false? A) To pass a structure by reference, pass the address of the structure variable. B) A way to pass an array by value is to create a structure with the array as a member then pass the name of the structure. C) To pass a structure by reference, pass the name of the structure variable. D) Passing large structures by reference is more efficient than passing large structures by...
In this project, you will be writing an object that
implements an ordered linked list with operator overload support
for insertions and deletions. The specification for the list object
will be provided upfront and you must design an implementation that
supports the provided specification. In addition, you will be given
a list of tasks that should be performed.
CIS 221 Programming II C++ Programming Project operator overloaded ordered Linked List object Overview In this assignment, the student will write a...