Answer:
link encryption
Explanation:
In e-mail, SSL/TLS provides link encryption.
The SSL is an acronym for Secured Socket Layer and it is one of the secured way of authenticating and encrypting data between a computer and the mail server.
In the case of a TLS, it is an acronym for Transport Layer Security and it basically is used for providing authentication and encryption of data between two communicating systems on a network.
This ultimately implies that, SSL/TLS are standard network protocols that provides data integrity and privacy to users when communicating over the internet or networking devices as they're made to encrypt user credentials and data from unauthorized access. The SSL/TLS are an application layer protocol used for the encryption of mails sent over the internet, in order to protect user information such as username and password.
Write a Console Java program that inserts 25 random integers in the range of 0 to 100 into a Linked List. (Use SecureRandom class from java.security package. SecureRandom rand
Answer:
follows are the program code to this question:
import java.security.SecureRandom;//import package SecureRandom
import java.util.*;//import uitl package for use input
class Main//defining class Main
{
public static void main(String[] args) //defining main method
{
int max = 25;//Defining an integer variable max
SecureRandom r = new SecureRandom();//creating SecureRandom class object
LinkedList<Integer> n= new LinkedList<Integer>();//Defining LinkedList class object
for(int i = 0; i <max; i++)//Defining for loop input value
{
int x = r.nextInt(100);//Defining integer variable x that use random function for hold value
n.add(x);//use LinkedList that use add method to add value in list
}
System.out.println("The original order of list: ");//print message
ListIterator it = n.listIterator();//create ListIterator object that hold LinkedList value
while(it.hasNext())//use while loop for check value
{
System.out.println(it.next());//use print method that prints ListIterator value
}
System.out.println("The reverse order of list: ");//print message
ListIterator itrev = n.listIterator(n.size());//create ListIterator object that hold LinkedList size value
while(itrev.hasPrevious())//Defining loop for print value in reverse order
{
System.out.println(itrev.previous());//print value
}
}
}
output:
please find the attached file.
Explanation:
In the above-given program inside the main method, an integer variable "max" is defined that holds an integer value, and in the next step, "SecureRandom and LinkedList" object is created, which is uses the for loop for in the loop it uses the "rand and add" method to assign value in the List.
In the next step, the "ListIterator" object has been created, that use while loop for creating the "ListIterator" object to hold size value and use the while loop to print the value in the reverse order and print its value.
2. Write a C program that generates following outputs. Each of the
outputs are nothing but 2-dimensional arrays, where ‘*’ represents
any random number. For all the problems below, you must use for
loops to initialize, insert and print the array elements as and where
needed. Hard-coded initialization/printing of arrays will receive a 0
grade. (5 + 5 + 5 = 15 Points)
i)
* 0 0 0
* * 0 0
* * * 0
* * * *
ii)
* * * *
0 * * *
0 0 * *
0 0 0 *
iii)
* 0 0 0
0 * 0 0
0 0 * 0
0 0 0 *
Answer:
#include <stdio.h>
int main(void)
{
int arr1[4][4];
int a;
printf("Enter a number:\n");
scanf("%d", &a);
for (int i=0; i<4; i++)
{
for(int j=0; j<4; j++)
{
if(j<=i)
{
arr1[i][j]=a;
}
else
{
arr1[i][j]=0;
}
}
}
for(int i=0; i<4; i++)
{
for(int j=0; j<4; j++)
{
printf("%d", arr1[i][j]);
}
printf("\n");
}
printf("\n");
int arr2[4][4];
int b;
printf("Enter a number:\n");
scanf("%d", &b);
for (int i=0; i<4; i++)
{
for(int j=0; j<4; j++)
{
if(j>=i)
{
arr1[i][j]=b;
}
else
{
arr1[i][j]=0;
}
}
}
for(int i=0; i<4; i++)
{
for(int j=0; j<4; j++)
{
printf("%d", arr1[i][j]);
}
printf("\n");
}
printf("\n");
int arr3[4][4];
int c;
printf("Enter a number:\n");
scanf("%d", &c);
for (int i=0; i<4; i++)
{
for(int j=0; j<4; j++)
{
if(j!=i)
{
arr1[i][j]=c;
}
else
{
arr1[i][j]=0;
}
}
}
for(int i=0; i<4; i++)
{
for(int j=0; j<4; j++)
{
printf("%d", arr1[i][j]);
}
printf("\n");
}
printf("\n");
return 0;
}
Explanation:
arr1[][] is for i
arr2[][] is for ii
arr3[][] is for iii
8
Drag each tile to the correct location. Not all tiles will be used.
Complete the code for defining a table using the correct tags.
Name
Age
Jill Smith
50
94
Eve Jackson
Match the president name and he expanded:
Franklin Roosevelt: Used veto power for political reasons.Harry Truman: Bypassed Congress to declare war in Korea.Andrew Jackson: presidential power, Issued the most, Executive orders.On March 15, 1767, Andrew Jackson was born; he passed away on June 8, 1845. He was to stand in for the "corrupt bargain" that, in his opinion, cost him the presidency and gave him the drive to win the next election no matter what.
According to the various president are the various decision. The president is the used of the power to take the decision.
Franklin Roosevelt: The veto power and the political reasons.
Harry Truman: The used right to declare war in Korea.
Andrew Jackson: president power, executive orders.
As a result, the significance of the Andrew Jackson are the aforementioned.
Learn more about on Andrew Jackson, here:
brainly.com/question/27920494
#SPJ1
The question seems to be incomplete, the complete question will be:
Drag the tiles to the correct boxes to complete the pairs.
Match each president’s name to the correct description of how he expanded.
Franklin Roosevelt, Harry Truman, Andrew Jackson
presidential power.
Issued the most
executive orders
Used veto power for
political reasons
Bypassed Congress to
declare war in Korea
Elaborate me rale OF ICT in Education.
Information and Communication Technology (ICT) plays a crucial role in transforming education by enhancing teaching and learning processes,
Elaborations on the role of ICT in education:Access to Information and Resources: ICT provides students and educators with access to a vast amount of information and educational resources. Through the internet, digital libraries, and online databases, learners can access a wide range of educational materials, research articles, e-books, videos, and interactive content. This enables them to explore diverse topics, conduct research, and stay updated with the latest information in their respective fields.
Enhancing Teaching and Learning: ICT tools and technologies enhance teaching and learning experiences. Multimedia presentations, educational software, simulations, and virtual reality applications engage students and make learning interactive and dynamic. Online platforms and learning management systems provide educators with the ability to deliver course materials, assignments, and assessments in a structured and organized manner. This fosters active learning, critical thinking, and problem-solving skills among students.
Learn more about ICT at
https://brainly.com/question/13724249
#SPJ1
complete question
Elaborate on the role OF ICT in Education
First Resource is offering a 5% discount off registration fees for all EventTypes except for Survey/Study.
In cell K11 enter a formula that will return 0.05 if the event is NOT a Survey/Study, otherwise return a blank value ("").
Use a VLOOKUP function to return the EventType from the EventDetails named range.
Use a NOT function so that any event type other than Survey/Study will return TRUE.
Use an IF function to return 0.05 for the value_if_true and "" for the value_if_false.
Incorporate an IFERROR function to return a blank value if the VLOOKUP function returns an error.
Format the result as Percentage with 0 decimal places and copy the formula down through K34.
Use a VLOOKUP function to return the EventType from the EventDetails named range. Use a NOT function so that any event type other than Survey/Study will return TRUE.
Use an IF function to return 0.05 for the value_if_true and "" for the value_if_false. Vlookup is a technique in excel which enables users to search for criterion values. It is vertical lookup function in excel which return a value from a different column.
Vlookup'select cell you want to look up in' select cell you want to lookup from' select column index number' true/false. where true is approximate match and false is exact match.
Learn more about technician on:
https://brainly.com/question/14290207
#SPJ1
7.2.5 height in meters
Can someone tell me what’s wrong and the correct code please
Answer:
72.5 m
Explanation:
7.2.5 is wrong
because every possible number can't have each decimal
Choose the comparison operator that will create a true statement in scratch
Answer:
the first one
Explanation:
think about it. 60 equals 60! this is true!
Answer:
A is correct
Explanation:
i took this same test
An individual receives a text message that appears to be a warning from a well-known order fulfillment company, informing them that the carrier has tried to deliver his package twice, and that if the individual does not contact them to claim it, the package will not be delivered. Analyze the scenario and select the social engineering technique being used.
A. SMiShing
B. Phishing
C. Vishing
D. Prepending
A. SMiShing . Analyze the scenario and select the social engineering technique being used.
What is scenario ?A scenario is a detailed outline of an event, situation, or series of actions. It is typically used to plan a course of action, establish expectations, or illustrate a possible outcome. Scenarios can be written for a variety of purposes, such as for business meetings or for educational purposes. They often include a timeline, relevant facts, and a description of the event or situation.
SMiShing is a type of social engineering technique that uses text messages to acquire personal information from an individual. In this scenario, the sender is using the text message to deceive the individual into believing that their package will not be delivered unless they contact the carrier, in order to obtain personal information from them.
To learn more about scenario
https://brainly.com/question/29673044
#SPJ4
3. You are working for a usability company that has recently completed a usability study of an airline ticketing system. They conducted a live AB testing of the original website and a new prototype your team developed. They brought in twenty participants into the lab and randomly assigned them to one of two groups: one group assigned to the original website, and the other assigned to the prototype. You are provided with the data and asked to perform a hypothesis test. Using the standard significance value (alpha level) of 5%, compute the four step t-test and report all important measurements. You can use a calculator or SPSS or online calculator to compute the t-test. (4 pts)
Answer:
Check the explanation
Explanation:
Let the population mean time on task of original website be \(\mu_1\) and that of new prototype be \(\mu_2\)
Here we are to test
\(H_0:\mu_1=\mu_2\;\;against\;\;H_1:\mu_1<\mu_2\)
The data are summarized as follows:
Sample 1 Sample 2
Sample size n=20 n=20
Sample mean \(\bar{x}_1=243.4\) \(\bar{x}_2=253.4\)
Sample SD s1=130.8901 s2=124.8199
The test statistic is obtained from online calculator as
t=-0.23
The p-value is given by 0.821
As the p-value is more than 0.05, we fail to reject the null hypothesis at 5% level of significance and hence conclude that there is no statistically significant difference between the original website and the prototype developed by the team at 5% level of significance.
how can a security framework k assist in the deisng and implementation of a secuiry infrastructure what isn information security governance
Answer:
on January 1st the new year begins rewrite and punctuate correctly
1. A rectangular boundary encloses a landscaping
layout represented by a number of geometric
objects. When hatching, the hatch pattern covers all
of the objects within the boundary. Which hatch
setting needs to be changed?
Separate hatches
Ignore island detection
O Outer island detection
Normal island detection
The hatch setting that needs to be changed is "Normal island detection".
What does detection mean?
Detection refers to the process of identifying or discovering the presence, existence, or occurrence of something. It involves using various methods, techniques, or tools to recognize, locate, or measure a particular object, substance, phenomenon, or condition.
Detection can be applied to a wide range of areas, such as:
Security: detecting threats, suspicious behavior, or illegal activities.Medicine: detecting diseases, abnormalities, or infections in the body.Science: detecting particles, energy, or signals in the environment.Technology: detecting errors, malfunctions, or vulnerabilities in software or hardware systems.Environmental monitoring: detecting pollutants, climate changes, or natural disasters.Detection is an important process that enables us to understand and respond to various situations and problems effectively. It often involves careful observation, analysis, and interpretation of data or information to make informed decisions and take appropriate actions.
Normal island detection is a hatch setting that detects islands or enclosed areas within the boundary and applies hatch patterns to them separately. However, in this case, the objective is to cover all the objects within the boundary with the hatch pattern, regardless of whether they are enclosed areas or not.
To achieve this, the hatch setting "Ignore island detection" should be selected. This will ensure that the hatch pattern covers all objects within the boundary, including those that would normally be considered islands and hatched separately.
To know more about technology visit:
https://brainly.com/question/13044551
#SPJ1
Where should a photographer place lights for a headshot? Headshot lighting is more important with darker backgrounds. The light should be at a 45-degree angle from the subject. The light should be in front of the subject. The third light should be the subject to form a ring of light around the subject’s hair.
Answer:
Headshot lighting is more important with darker backgrounds. The
(key) light should be at a 45-degree angle from the subject. The
(fill) light should be in front of the subject. The third light should be
(behind) the subject to form a ring of light around the subject’s hair.
Explanation:
i searched it up individually and thats what i got
"An operating system is an interface between human operators and application software". Justify this statement with examples of operating system known to you.
An operating system acts as the interface between the user and the system hardware. It is responsible for all functions of the computer system.
It is also responsible for handling both software and hardware components and maintaining the device's working properly. All computer programs and applications need an operating system to perform any task. Users are the most common operating system component that controls and wants to make things by inputting data and running several apps and services.
After that comes the task of implementation, which manages all of the computer's operations and helps in the movement of various functions, including photographs, videos, worksheets, etc. The operating system provides facilities that help in the operation of apps and utilities through proper programming.
learn more about operating systems at -
https://brainly.com/question/1033563
Why is it best to serve cheese with plain breads or crackers?
Answer:Here's why it works: Club crackers are engineered to be the perfect amount of buttery and salty, which means that, sometimes, they're all you can taste if paired with the wrong cheese.
Explanation:
In 25 words or fewer, explain how u can help maintain a productive work environment while on the job
I would ensure side attractions like gisting or surfing the internet while I am supposed to be working are eliminated while also personalizing my space.
how to write a simple bash script in linux
Writing a simple bash script in Linux involves a few steps to create a script file, define its execution permissions, write the desired commands, and save the file. Bash scripts allow for automating tasks and executing multiple commands sequentially.
Choose a text editor: Select a text editor of your preference, such as nano, vi, or gedit, to create and edit the script file.
Create a new file: Open the text editor and create a new file with a .sh extension. For example, you can use the command nano script.sh to create a new file named "script.sh" using the nano editor.
Define the shebang: Start the script file with a shebang line, which tells the system the interpreter to use. The most common shebang for bash scripts is #!/bin/bash. It indicates that the script should be executed using the Bash shell.
Write script commands: In the script file, write the desired commands that you want to execute. For example, you can use basic commands like echo, if statements, loops, or other Linux commands to perform various tasks.
Save the file: Save the script file after writing the commands. In the nano editor, you can press Ctrl + O to save the file and Ctrl + X to exit the editor.
Set execution permissions: Make the script file executable using the chmod command. For example, you can use chmod +x script.sh to give execute permissions to the owner of the script file.
Execute the script: Run the script by entering its filename preceded by "./". For example, if your script file is named "script.sh", you can run it using ./script.sh. The script will execute the commands written in it.
Test and modify: Run the script and verify its functionality. If needed, make modifications to the script file and repeat the testing process until you achieve the desired results.
By following these steps, you can create a simple bash script in Linux. Bash scripting allows you to automate tasks, execute commands sequentially, and perform various operations in a convenient and efficient manner.
For more such questions on Linux, click on:
https://brainly.com/question/12853667
#SPJ8
Python question
The following code achieves the task of adding commas and apostrophes, therefore splitting names in the list. However, in the case where both first and last names are given how would I "tell"/write a code that understands the last name and doesn't split them both. For example 'Jack Hansen' as a whole, rather than 'Jack' 'Hansen'.
names = "Jack Tomas Ponce Ana Mike Jenny"
newList = list(map(str, names.split()))
print(newList) #now the new list has comma, and apostrophe
Answer:
You can use regular expressions to match patterns in the names and split them accordingly. One way to do this is to use the re.split() function, which allows you to split a string based on a regular expression.
For example, you can use the regular expression (?<=[A-Z])\s(?=[A-Z]) to match a space between two capital letters, indicating a first and last name. Then use the re.split() function to split the names based on this regular expression.
Here is an example of how you can use this approach to split the names in your list:
(Picture attached)
This will give you the output ['Jack', 'Tomas', 'Ponce', 'Ana', 'Mike', 'Jenny', 'Jack Hansen']. As you can see, the name "Jack Hansen" is not split, as it matches the pattern of first and last name.
It's worth noting that this approach assumes that all first and last names will have the first letter capitalized and the last names capitalized too. If this is not the case in your data, you may need to adjust the regular expression accordingly.
Question 3 (1 point)
an assortment or set of type or characters all of one style and sometimes one size.
italic
O underline
font
Obold
an assortment or set of type or charactera all of one style and sometimes one size. Ans: italic
Assign a variable madLib to a function expression that has five parameters in the order: an adverb, two nouns, an adjective and a verb. The function should return a mad lib string value by substituting the parameter values into the following template:
The [adjective] [noun1] [adverb] [verb] the [noun2]. For example: madLib("quietly", "dog", "moon", "lazy", "smashed") returns "The lazy dog quietly smashed the moon.". 1 2 3 4 5 6 7 /* Your solution goes here */ /* Code will be tested once with parameters: "quietly", "dog", "moon", "lazy", "smashed", and again with parameters: "gently", "rat", "city", "bored", "became" */ console.log(madLib("quietly", "dog", "moon", "lazy", "smashed")); 1 2 3 4 Check Next 1
Answer:
The function is written in C++:
void madLib(string adjective,string noun1,string adverb,string verb,string noun2){
cout<<"The "+verb+" "+noun1+" "+adjective+" "+noun2+" the "+adverb;
}
Explanation:
This line defines the function
void madLib(string adjective,string noun1,string adverb,string verb,string noun2){
This line generates and returns the output string
cout<<"The "+verb+" "+noun1+" "+adjective+" "+noun2+" the "+adverb;
NB: I've added the full source code as an attachment where you can test various input strings
What are the Components of a CPU?
What is the default layout position for images added to a Word 2016 document?
A) square, where the text wraps around an image around a square border
B) through, where the text wraps around an image with irregular borders
C) in front of the text, where the image is placed over the text
D) in-line, with the text where the text stays with the image
Answer:
D
Explanation:
Hope it works
Answer:
D) in-line, with the text where the text stays with the image
Explanation:
Just did it in ED.
I want to write a Java program to display the multiplication table for the number entered by the user and the values doesn’t exceed 100 .For example if the user enter 3 the output should be like this :
3
6
9
12
15
18
21
24
27
30
33
36
39
42
45
48
51
54
57
60
63
66
69
72
75
78
81
84
87
90
93
96
99
Answer:
yes that is correct
Explanation:
hopefully this helps good luck
Given integer variables seedVal and highest, generate three random numbers that are less than highest and greater than or equal to 0. Each number generated is output. Lastly, the average of the three numbers is output.
Answer:
Here's a Python code snippet to generate three random numbers between 0 and highest (exclusive), and then calculate the average of these numbers:
import random
seedVal = int(input("Enter seed value: "))
highest = int(input("Enter highest value: "))
random.seed(seedVal)
num1 = random.randint(0, highest)
num2 = random.randint(0, highest)
num3 = random.randint(0, highest)
print("First number:", num1)
print("Second number:", num2)
print("Third number:", num3)
average = (num1 + num2 + num3) / 3
print("Average:", average)
Write a paragraph discussing privacy issues on the internet
and their impact on human lives.
Explanation:
internent had a impact on human lives because it is very popular and it brought in phones so about evrbody in the world has internent and it impacted work around the world and changed the world alot.
Why might a programmer use a "linked list" instead of an "array" to store data in a computer program?
The programmer uses a “linked list” instead of an “array” to store data due to its dynamic nature and quicker insertion/deletion time complexity, linked lists.
What is a linked list?A linked list is a linear line or collection of data whose data is not organized in a way in a physical memory. A data structure consists of collecting nodes.
The array is also a collection of data of elements. They are identified by an array index and array key.
Thus, the programmer used a “linked list” instead of an “array” because It is the quick and easy way.
To learn more about the linked list, refer to the link:
https://brainly.com/question/13144722
#SPJ1
What fictional place would you most like to go to? Its your opinion!
Mount olympus
Explanation:
Because its the home of the greek gods and i feel like it would be cool to meet the gods
In what way can an employee demonstrate commitment?
Answer:
Come to work on time ready to work. Always work above and beyond. ... Come to work on time, follow all rules, do not talk about people, and be positive get along with coworkers.
Explanation:
An employee can demonstrate commitment to their job and organization in several ways.
First and foremost, they show dedication and enthusiasm by consistently meeting deadlines, going above and beyond to achieve goals, and taking ownership of their responsibilities.
Being punctual and reliable also reflects commitment. Employees who actively participate in team efforts, support colleagues, and offer innovative ideas exhibit their dedication to the company's success.
Demonstrating a willingness to learn and grow by seeking additional training or taking on new challenges further showcases commitment.
Ultimately, a committed employee is driven by a genuine passion for their work, a strong work ethic, and a sense of loyalty to their organization's mission and values.
Know more about employee commitment:
https://brainly.com/question/34152205
#SPJ6
what is data abstraction and data independence?
Data abstraction and data independence are two key concepts in computer science and database management systems. They are closely related and aim to improve the efficiency, flexibility, and maintainability of data management.
What is data abstraction and data independence?The definitions of these two are:
Data Abstraction:
Data abstraction refers to the process of hiding the implementation details of data and providing a simplified view or interface to interact with it. It allows users to focus on the essential aspects of data without being concerned about the underlying complexities. In programming languages, data abstraction is often achieved through the use of abstract data types (ADTs) or classes.
By abstracting data, programmers can create high-level representations of data entities, defining their properties and operations.
Data Independence:
Data independence refers to the ability to modify the data storage structures and organization without affecting the higher-level applications or programs that use the data. It allows for changes to be made to the database system without requiring corresponding modifications to the applications that rely on that data. Data independence provides flexibility, scalability, and ease of maintenance in database systems.
Learn more about data at:
https://brainly.com/question/179886
#SPJ1
Codehs 9.4.6 word counts
The amount of words in a document or passage of text is referred to as the word count.
Why is word count important?When a manuscript must keep inside a specified amount of words, word counting may be required. This may be especially true in education, judicial procedures, media, and advertising.
The word count is significant since it allows you to choose your readers. For example, if you create a novel that is 100,000 words long, there will inevitably be some readers who will find it unsuitable (due to the word length).
Learn more about word count:
https://brainly.com/question/31310672
#SPJ1
Part 1: For this assignment, call it assign0 Implement the following library and driver program under assign0: Your library will be consisting of myio.h and myio.c. The function prototypes as well as more explanations are listed in myio.h. Please download it and accordingly implement the exported functions in myio.c. Basically, you are asked to develop a simple I/O library which exports a few functions to simplify the reading of an integer, a double, and more importantly a string (whole line). In contrast to standard I/O functions that can read strings (e.g., scanf with "%s", fgets) into a given static size buffer, your function should read the given input line of characters terminated by a newline character into a dynamically allocated and resized buffer based on the length of the given input line. Also your functions should check for possible errors (e.g., not an integer, not a double, illigal input, no memory etc.) and appropriately handle them. Then write a driver program driver.c that can simply use the functions from myio library. Specifically, your driver program should get four command-line arguments: x y z output_filename. It then prompts/reads x many integers, y many doubles, and z many lines, and prints them into a file called output_filename.txt. Possible errors should be printed on stderr.
myio.h file
/*
* File: myio.h
* Version: 1.0
* -----------------------------------------------------
* This interface provides access to a basic library of
* functions that simplify the reading of input data.
*/
#ifndef _myio_h
#define _myio_h
/*
* Function: ReadInteger
* Usage: i = ReadInteger();
* ------------------------
* ReadInteger reads a line of text from standard input and scans
* it as an integer. The integer value is returned. If an
* integer cannot be scanned or if more characters follow the
* number, the user is given a chance to retry.
*/
int ReadInteger(void);
/*
* Function: ReadDouble
* Usage: x = ReadDouble();
* ---------------------
* ReadDouble reads a line of text from standard input and scans
* it as a double. If the number cannot be scanned or if extra
* characters follow after the number ends, the user is given
* a chance to reenter the value.
*/
double ReadDouble(void);
/*
* Function: ReadLine
* Usage: s = ReadLine();
* ---------------------
* ReadLine reads a line of text from standard input and returns
* the line as a string. The newline character that terminates
* the input is not stored as part of the string.
*/
char *ReadLine(void);
/*
* Function: ReadLine
* Usage: s = ReadLine(infile);
* ----------------------------
* ReadLineFile reads a line of text from the input file and
* returns the line as a string. The newline character
* that terminates the input is not stored as part of the
* string. The ReadLine function returns NULL if infile
* is at the end-of-file position. Actually, above ReadLine();
* can simply be implemented as return(ReadLineFile(stdin)); */
char *ReadLineFile(FILE *infile);
#endif
Answer:
Explanation:
PROGRAM
main.c
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "myio.h"
int checkInt(char *arg);
int main(int argc, char *argv[]) {
int doubles, i, ints, lines;
char newline;
FILE *out;
int x, y, z;
newline = '\n';
if (argc != 5) {
printf("Usage is x y z output_filename\n");
return 0;
}
if (checkInt(argv[1]) != 0)
return 0;
ints = atoi(argv[1]);
if (checkInt(argv[2]) != 0)
return 0;
doubles = atoi(argv[2]);
if (checkInt(argv[3]) != 0)
return 0;
lines = atoi(argv[3]);
out = fopen(argv[4], "a");
if (out == NULL) {
perror("File could not be opened");
return 0;
}
for (x = 0; x < ints; x++) {
int n = ReadInteger();
printf("%d\n", n);
fprintf(out, "%d\n", n);
}
for (y = 0; y < doubles; y++) {
double d = ReadDouble();
printf("%lf\n", d);
fprintf(out, "%lf\n", d);
}
for (z = 0; z < lines; z++) {
char *l = ReadLine();
printf("%s\n", l);
fprintf(out, "%s\n", l);
free(l);
}
fclose(out);
return 0;
}
int checkInt(char *arg) {
int x;
x = 0;
while (arg[x] != '\0') {
if (arg[x] > '9' || arg[x] < '0') {
printf("Improper input. x, y, and z must be ints.\n");
return -1;
}
x++;
}
return 0;
}
myio.c
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
char *ReadInput(int fd) {
char buf[BUFSIZ];
int i;
char *input;
int r, ret, x;
i = 1;
r = 0;
ret = 1;
input = calloc(BUFSIZ, sizeof(char));
while (ret > 0) {
ret = read(fd, &buf, BUFSIZ);
for (x = 0; x < BUFSIZ; x++) {
if (buf[x] == '\n' || buf[x] == EOF) {
ret = -1;
break;
}
input[x*i] = buf[x];
r++;
}
i++;
if (ret != -1)
input = realloc(input, BUFSIZ*i);
}
if (r == 0)
return NULL;
input[r] = '\0';
input = realloc(input, r+1);
return(input);
}
int ReadInteger() {
char *input;
int go, num, x;
go = 0;
do {
go = 0;
printf("Input an integer\n");
input = ReadInput(STDIN_FILENO);
for (x = 0; x < INT_MAX; x++) {
if (x == 0&& input[x] == '-')
continue;
if (input[x] == 0)
break;
else if (input[x]> '9' || input[x] < '0') {
go = 1;
printf("Improper input\n");
break;
}
}
} while (go == 1);
num = atoi(input);
free(input);
return num;
}
double ReadDouble(void) {
int dec, exp;
char *input;
int go;
double num;
int x;
do {
go = 0;
dec = 0;
exp = 0;
printf("Input a double\n");
input = ReadInput(STDIN_FILENO);
for (x = 0; x < INT_MAX; x++) {
if (x == 0&& input[x] == '-')
continue;
if (input[x] == 0)
break;
else if (input[x] == '.' && dec == 0)
dec = 1;
else if (x != 0&& (input[x] == 'e' || input[x] == 'E') && exp == 0) {
dec = 1;
exp = 1;
}
else if (input[x]> '9' || input[x] < '0') {
go = 1;
printf("Improper input\n");
break;
}
}
} while (go == 1);
num = strtod(input, NULL);
free(input);
return num;
}
char *ReadLine(void) {
printf("Input a line\n");
return(ReadInput(STDIN_FILENO));
}
char *ReadLineFile(FILE *infile) {
int fd;
fd = fileno(infile);
return(ReadInput(fd));
}
myio.h
#ifndef _myio_h
#define _myio_h
/*
* Function: ReadInteger
* Usage: i = ReadInteger();
* ------------------------
* ReadInteger reads a line of text from standard input and scans
* it as an integer. The integer value is returned. If an
* integer cannot be scanned or if more characters follow the
* number, the user is given a chance to retry.
*/
int ReadInteger(void);
/*
* Function: ReadDouble
* Usage: x = ReadDouble();
* ---------------------
* ReadDouble reads a line of text from standard input and scans
* it as a double. If the number cannot be scanned or if extra
* characters follow after the number ends, the user is given
* a chance to reenter the value.
*/
double ReadDouble(void);
/*
* Function: ReadLine
* Usage: s = ReadLine();
* ---------------------
* ReadLine reads a line of text from standard input and returns
* the line as a string. The newline character that terminates
* the input is not stored as part of the string.
*/
char *ReadLine(void);
/*
* Function: ReadLine
* Usage: s = ReadLine(infile);
* ----------------------------
* ReadLineFile reads a line of text from the input file and
* returns the line as a string. The newline character
* that terminates the input is not stored as part of the
* string. The ReadLine function returns NULL if infile
* is at the end-of-file position. Actually, above ReadLine();
* can simply be implemented as return(ReadLineFile(stdin)); */
char *ReadLineFile(FILE *infile);