SlideShare a Scribd company logo
1 of 19
CSE 220 Assignment 3 Hints and Tips
Some hints for approaching this assignment is as follows:
Approaching the assignment :
General Overview
It would be a good thing if before you start your assignment you
try to decompose the problem
you are trying to solve into small segments. Each segment can
be then written and tested for
any bugs or errors. Doing so will help you learn the true nature
of functions and how effective
they can be.
The assignment requires that you read a string from either the
stdin or a file and then count the
frequency of words in it and display it to stdout or to a file. We
can look at this in the following
way :
1) Read an input from one of two sources
a. stdin
b. an input file
2) Find the frequency of words from input string
3) Write the words and their frequency to one of two ouputs
a. Stdout
b. An outputifle
One way of solving the problem
One way of approaching this code would be to create a structure
which will hold a word and its
frequency and then create an array of that structure to
accommodate all the unique words in
the input. So you would create a structure as follows:
struct wordStorage
{
char word[50];
int count;
};
Then when you want to create an array of that structure you
would write it out as :
struct wordStorage arr[size];
So we created an array to of size number of elements of the
structure wordStorage created
above.
This array can then be used to keep track of all the unique
words you come across in the input
string and their frequencies. You can create arrays of this
structure after you have defined the
structure itself.
You could then use the following prototypes in your code:
1. void decomposeToArray(char *para,char wordarr[1000][50])
This function takes in a string para and stores all the words in
that string. You can
modify it to return the array of words containing all the words
using –
char** decomposeToArray(char *para,char wordarr[1000][50]);
2. void frequencyOfWords(struct wordStorage *wordarr,char
wordList[1000][50])
This function takes in a structure array in which element
contains a word and its
frequency and the array of words that you created using
decomposeToArray(args).
Instead of using a void function you can modify it so that it
stores the words and
their frequency as an array of the given structure and then
returns the structure
array. The prototype then becomes –
struct wordStorage* frequencyOfWords(wordList[1000][50])
3. void readFromFile(char *filename,char sentence[1000])
This function takes in the name of a file and a string to store all
the contents of the
file. You can use pass by reference to keep track of the string
that is storing the
string OR you could modify the function to read the name of a
file and return a
string using:
char* readFromFile(char *filename)
4. void writeToFile(char *filename,struct wordStorage
*wordarr);
This function prints the contents of the structure array wordarr
into the file whose
name is specified by filename
5. void displayWords(struct wordStorage *wordarr);
This functions writes the contents of the structure array (
containing words and their
frequencies) on the standard output i.e. your display
The prototypes mentioned above will then need to be linked in
the main function depending on
the arguments that are passed through the command line.
For example :
You can read a string from stdin and use
decomposeToArray(args) to break your input
string into a list of words. This list can be stored as a 2D
character array and then sent to the
function
frequencyOfWords(list_you_got_from_decomposeToArray) and
the function will
return a structure array that consists of all the unique words in
the string and their frequencies.
[Note : frequencyOfWords() must have a structure array inside
it in order to be able to return it. If you are using
the void frequencyOfWords(struct wordStorage *wordarr,char
wordList[1000][50]) variation, then you will need
to use Pass By Reference to handle it.]
Dealing with 2D Character arrays in C:
2D arrays in C can be a little overwhelming to understand
especially when dealing with strings.
It is important to understand the structure of the 2D character
array while dealing with an array
of strings.
For example if you were to store a string in a single
dimensional character array you could do it
in the following ways :
char *array=”This is a string in C!”;
char array[]=”This is a string in C!”;
char array[100];
strcpy(array,”This will also be a string!”);
So you can see that a string in C is basically an array of
characters.
When dealing with an array of strings, you need to look at it
like an array of strings or in our
case an array of arrays ( where each string is an array!)
So if we were to accept a sentence from the user and then store
each word in an array, we
would need a 2D array to do so.
Think of it like this :
char words[rows][cols];
Each row is a word and each column in a row is a character
belonging to a certain word.
So when you find a character in a word, you add it to the
column of the present row ( the
present word you are looking at). If a word is completed, then
you go to the next row.
The way to approach this would be to first accept the sentence
from the user. Then try to
decompose that sentence by selecting end of word markers ( or
string delimiters). In the
example which follows below, we assume that the space (‘ ‘)
character is what signifies the end
of a word. So if we had a string like : “This is a new sentence “,
then we should be able to break
it into 5 words where each word ends with a space character(‘
‘). Now once we have set our
word delimiters we need to check each character in the input
string and decide whether a word
is completely read or not. In order to do so, run a loop, extract
each character into a dummy
variable and check if it is your word delimiter ( here we use
space only, you should consider
punctuation marks and so on). If a character is not the word
delimiter, add it to the word count
2D array along the second dimension( columns in the 2D array)
.Otherwise if it is a word
delimiter, then a word has been completely read from the input
string – so we increment the
counter on the 1st dimension ( rows of the 2D array used) of the
2D array to go to the next word
slot.
For example :
char words[100][100]; // Assume that we are going to have a
maximum of 100 words of size
100 characters each
char sentence[1000]; //Assuming that the input string is just
composed of 1000 characters
char ch; // A dummy variable to act as a buffer for the input
string
int len,wc=0,c=0,i=0;
printf("Enter a sentence:");
//Using the %[n]s we can force the scanf to ignore n
characters. This allows us to input n
scanf("%[n]s",&sentence);
strcat(sentence," "); // I am assuming that every word in the
string ends with a space
len=strlen(sentence); //Calculate the length of the string input
//The next part will show you how each word is read from the
string and then stored inside a
// 2D array for processing later
for(i=0;i<len;i++)
{
ch=sentence[i]; //Read each character from the input string
if(ch==' ') // If you have reached a space (‘ ‘)character , it
implies a word is completely
read
{
words[wc][c++]='0'; // Terminate each string with a ‘0’
character
wc++; // We just finished adding a new word
c=0; //Reset the counter which keeps track of the letter inside
the word
}
else // If you read anything other than a ‘ ‘, add it as a letter to
the present word
{
words[wc][c++]=ch;
}
}
Reflection Requirement:
Ready for a completely open-ended reflection response? If so,
then go for it!
If not, here are some suggestions to guide your thought process.
Potential topics to address in your reflection:
Why are “standards” so prevalent in education today? Why are
“accountability” and “standards” the buzz words in many
professions and society today? Isn’t it good to have standards in
your life? So why is education any different?
Some of you may have understood that the prevalent use of
standards was just the way that schools are. If so, what was
your reaction to Eisner’s view of the standards system in “The
Centrality of Curriculum and the Function of Standards”?
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
int numWords;
int numUniqWords;
struct wordStorage
{
char word[50];
int count;
};
/* You can modify the functions to return objects instead of
using void and pass by reference */
/* This is your choice and depends on how you wish to code it
*/
void decomposeToArray(char *para,char wordarr[1000][50]);
void frequencyOfWords(struct wordStorage *wordarr,char
wordList[1000][50]);
void readFromFile(char *filename,char sentence[1000]);;
void writeToFile(char *filename,struct wordStorage *wordarr);
void displayWords(struct wordStorage *wordarr);
/* This function is optional and you can use it to create a robust
program that can read and write from
any of the sources. You adjust the read and write values and
according to some set values ( eg 0=>STDIO and 1=>FILE)
you call the required functions to process your input
*/
void executeCode(int read,int write,char readFile[100],char
writeFile[100]);
int main(int argc,char *argv[])
{
int i,j;
char readFile[100];
char writeFile[100];
int flag=0; // Checks for -h option. 1=FOUND , 0=NOT
FOUND
if(argc<=1)
{
// Fill code here when there are no options given i.e.
the time when you read from STDIN and write to STDOUT
}
else if(argc>=2)
{
for(i=1;i<argc;i++)
{
if(strcmp(argv[i],"-h")==0)
{
printf("nRead English Language text and
calculate word frequencies.n");
printf("nn");
printf("-h Display this help
message.n");
printf("-f file Read text from given
file.n");
printf("-o file Write program output to
file.n");
printf("-v Display version info and
exit.n");
flag=1;
break;
}
}
//Write code to link the functions and construct your
program overall
return 0;
}
void decomposeToArray(char *para,char wordarr[1000][50])
{
// Fill your code here
}
void frequencyOfWords(struct wordStorage *wordarr,char
wordList[1000][50])
{
// Fill your code here
}
void readFromFile(char *filename,char sentence[1000])
{
// Fill your code here
}
void writeToFile(char *filename,struct wordStorage *wordarr)
{
// Fill your code here
}
void displayWords(struct wordStorage *wordarr)
{
// Fill your code here
}
CSE220 Programming for Computer Engineering Assignment 3
CSE220 Page 1
Assignment 3 – CSE220 – Fall 2015
1. Instructions
This is an individual assignment. Please start working on it as
soon as possible and ask for help if you need it.
Your project solution document must be uploaded to Blackboard
by the assignment deadline. Section 6 de-
scribes what to submit and by when; read it now.
2. Assignment Objectives
1. Write a basic C program.
2. Define and use local variables and global constants.
3. Define and use one-dimensional arrays.
4. Define and use C-string variables and C-string arrays.
5. Use flow of control constructs such as if-statements, for-
loops, and while-loops.
6. Define and use C characters and Strings
7. Parse the command line for arguments and options.
8. Use functions from stdio.h to perform I/O with stdin/stdout
and text files.
9. Understand the difference between declaration and definition.
10. Understand the difference between static and nonstatic
functions, variables, and constants.
11. Use the GCC C compiler to compile a C program. Use the
GDB debugger to debug a program.
3. Software Requirements
Your project is to write a complete C program which will read
several lines of text and prints a table indicating
the number of occurrences of each different word in the text.
The program should include the words in the table
in the same order in which they appear in the text. For example,
the lines
To be, or not to be: that is the question:
Whether ‘t is nobler in the mind to suffer
Contains the word “to” three times, “be” two times, “or” once,
and so on..
By default, the program will read input from stdin and send
output to stdout. The -f file option will cause the
program to read the input from the text file named file and the -
o file option will cause the program to write the
output to the file named file. The options are,
-h Display a help message and exit.
-f file Read input from the text file named file.
-o file Output the results to the file named file.
-v Display version info and exit.
CSE220 Programming for Computer Engineering Assignment 3
CSE220 Page 2
The -h Option
Your program shall output the following help message when the
-h option is specified,
$ ./hw3 -h
Usage: hw3 [option]...
Read English language text and calculate word frequencies.
Options:
-h Display this help message and exit.
-f file Read the text from “file”.
-o file Write the results to “file.n
-v Display version info and exit.n
By default, text is read from stdin and the results are sent to
stdout.
The -h option has higher precedence than all of the other
options, meaning that if it specified along with other
options, the program shall act as if -h were the only option,
$ ./hw3 -f foo -o prog -h -v
The above help message is displayed
The -v Option
Your program shall output the following version information
when the -v option is specified,
$ ./hw3 -v
hw3: version 1.0 (2015.8.13)
Faye. Navabi <[email protected]>
Replace my name and email address with your name and email
address, and replace the date with the date you
complete your program. If -h and -v are both specified on the
command line, then -h shall take precedence, i.e.,
display the help message and exit.
$ ./hw3 -v -h
The above help message is displayed
The -f and -o Options
If -f or -o is specified without a file name, display an error
message and terminate,
CSE220 Programming for Computer Engineering Assignment 3
CSE220 Page 3
$ ./hw3 -f
hw3: expecting argument following -f
$ hw3 -o
hw3: expecting argument following -o
If the file specified with -f cannot be opened for reading
(probably because it does not exist or the user made a
typo), then display an error message,
$ ./hw3 -f foo
hw3: could not open foo
If the file specified with -o cannot be opened for writing
(probably because the file already exists and is read-
only), then display an error message,
$ ./hw3 -o /bin/date
hw3: could not open /bin/date
Default Input and Output
By default, the program shall read the input from stdin and shall
write the output to stdout,
$ ./hw3
Parting is such sweet sorrow. The dog ate the cat. Goodbye.
^D
The output is then displayed on the terminal window.
4.Submission
When your project is complete, type make clean in your source
code directory to clean your object files. the
Then create a bzipped tarball named cse220-f15-hw3-
lastname.tar.bz2, where lastname is your last name.
$ make clean
$ cd ..
$ tar cvjf cse220-f15-hw3-lastname.tar.bz2 cse220-hw3
Submit this tarball to Blackboard using the assignment
submission link before the deadline.
CSE 220 Assignment 3 Hints and Tips  Some hints for approa.docx

More Related Content

Similar to CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx

DOES NOT NEED TO BE ANSWERED UNTIL NOV 13thWords AssignmentRober.pdf
DOES NOT NEED TO BE ANSWERED UNTIL NOV 13thWords AssignmentRober.pdfDOES NOT NEED TO BE ANSWERED UNTIL NOV 13thWords AssignmentRober.pdf
DOES NOT NEED TO BE ANSWERED UNTIL NOV 13thWords AssignmentRober.pdfarchanaemporium
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingRasan Samarasinghe
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arraysphanleson
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptxJawadTanvir
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programmingnmahi96
 
In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...Indu32
 
Maxbox starter20
Maxbox starter20Maxbox starter20
Maxbox starter20Max Kleiner
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE jatin batra
 
Java string handling
Java string handlingJava string handling
Java string handlingSalman Khan
 
Module 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfModule 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfMegMeg17
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and stringsRai University
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsRaghu nath
 

Similar to CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx (20)

String handling
String handlingString handling
String handling
 
M C6java7
M C6java7M C6java7
M C6java7
 
LectureNotes-04-DSA
LectureNotes-04-DSALectureNotes-04-DSA
LectureNotes-04-DSA
 
DOES NOT NEED TO BE ANSWERED UNTIL NOV 13thWords AssignmentRober.pdf
DOES NOT NEED TO BE ANSWERED UNTIL NOV 13thWords AssignmentRober.pdfDOES NOT NEED TO BE ANSWERED UNTIL NOV 13thWords AssignmentRober.pdf
DOES NOT NEED TO BE ANSWERED UNTIL NOV 13thWords AssignmentRober.pdf
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
 
Ch09
Ch09Ch09
Ch09
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arrays
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
 
C Programming Unit-3
C Programming Unit-3C Programming Unit-3
C Programming Unit-3
 
In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...
 
Maxbox starter20
Maxbox starter20Maxbox starter20
Maxbox starter20
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Module 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfModule 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdf
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and strings
 
COm1407: Character & Strings
COm1407: Character & StringsCOm1407: Character & Strings
COm1407: Character & Strings
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 

More from faithxdunce63732

Assignment DetailsScenario You are member of a prisoner revie.docx
Assignment DetailsScenario You are member of a prisoner revie.docxAssignment DetailsScenario You are member of a prisoner revie.docx
Assignment DetailsScenario You are member of a prisoner revie.docxfaithxdunce63732
 
Assignment DetailsScenario You are an investigator for Child .docx
Assignment DetailsScenario You are an investigator for Child .docxAssignment DetailsScenario You are an investigator for Child .docx
Assignment DetailsScenario You are an investigator for Child .docxfaithxdunce63732
 
Assignment DetailsScenario You are a new patrol officer in a .docx
Assignment DetailsScenario You are a new patrol officer in a .docxAssignment DetailsScenario You are a new patrol officer in a .docx
Assignment DetailsScenario You are a new patrol officer in a .docxfaithxdunce63732
 
Assignment DetailsScenario Generally, we have considered sexual.docx
Assignment DetailsScenario Generally, we have considered sexual.docxAssignment DetailsScenario Generally, we have considered sexual.docx
Assignment DetailsScenario Generally, we have considered sexual.docxfaithxdunce63732
 
Assignment DetailsPower’s on, Power’s Off!How convenient is.docx
Assignment DetailsPower’s on, Power’s Off!How convenient is.docxAssignment DetailsPower’s on, Power’s Off!How convenient is.docx
Assignment DetailsPower’s on, Power’s Off!How convenient is.docxfaithxdunce63732
 
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docx
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docxAssignment DetailsIn 1908, playwright Israel Zangwill referred to .docx
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docxfaithxdunce63732
 
Assignment DetailsPart IRespond to the following.docx
Assignment DetailsPart IRespond to the following.docxAssignment DetailsPart IRespond to the following.docx
Assignment DetailsPart IRespond to the following.docxfaithxdunce63732
 
Assignment DetailsPlease discuss the following in your main post.docx
Assignment DetailsPlease discuss the following in your main post.docxAssignment DetailsPlease discuss the following in your main post.docx
Assignment DetailsPlease discuss the following in your main post.docxfaithxdunce63732
 
Assignment DetailsPennsylvania was the leader in sentencing and .docx
Assignment DetailsPennsylvania was the leader in sentencing and .docxAssignment DetailsPennsylvania was the leader in sentencing and .docx
Assignment DetailsPennsylvania was the leader in sentencing and .docxfaithxdunce63732
 
Assignment DetailsPart IRespond to the followingReview .docx
Assignment DetailsPart IRespond to the followingReview .docxAssignment DetailsPart IRespond to the followingReview .docx
Assignment DetailsPart IRespond to the followingReview .docxfaithxdunce63732
 
Assignment DetailsPart IRespond to the following questio.docx
Assignment DetailsPart IRespond to the following questio.docxAssignment DetailsPart IRespond to the following questio.docx
Assignment DetailsPart IRespond to the following questio.docxfaithxdunce63732
 
Assignment DetailsPart IRespond to the following questions.docx
Assignment DetailsPart IRespond to the following questions.docxAssignment DetailsPart IRespond to the following questions.docx
Assignment DetailsPart IRespond to the following questions.docxfaithxdunce63732
 
Assignment DetailsOne thing that unites all humans—despite cultu.docx
Assignment DetailsOne thing that unites all humans—despite cultu.docxAssignment DetailsOne thing that unites all humans—despite cultu.docx
Assignment DetailsOne thing that unites all humans—despite cultu.docxfaithxdunce63732
 
Assignment DetailsMN551Develop cooperative relationships with.docx
Assignment DetailsMN551Develop cooperative relationships with.docxAssignment DetailsMN551Develop cooperative relationships with.docx
Assignment DetailsMN551Develop cooperative relationships with.docxfaithxdunce63732
 
Assignment DetailsInfluence ProcessesYou have been encourag.docx
Assignment DetailsInfluence ProcessesYou have been encourag.docxAssignment DetailsInfluence ProcessesYou have been encourag.docx
Assignment DetailsInfluence ProcessesYou have been encourag.docxfaithxdunce63732
 
Assignment DetailsIn this assignment, you will identify and .docx
Assignment DetailsIn this assignment, you will identify and .docxAssignment DetailsIn this assignment, you will identify and .docx
Assignment DetailsIn this assignment, you will identify and .docxfaithxdunce63732
 
Assignment DetailsFinancial statements are the primary means of .docx
Assignment DetailsFinancial statements are the primary means of .docxAssignment DetailsFinancial statements are the primary means of .docx
Assignment DetailsFinancial statements are the primary means of .docxfaithxdunce63732
 
Assignment DetailsIn this assignment, you will identify a pr.docx
Assignment DetailsIn this assignment, you will identify a pr.docxAssignment DetailsIn this assignment, you will identify a pr.docx
Assignment DetailsIn this assignment, you will identify a pr.docxfaithxdunce63732
 
Assignment DetailsHealth information technology (health IT) .docx
Assignment DetailsHealth information technology (health IT) .docxAssignment DetailsHealth information technology (health IT) .docx
Assignment DetailsHealth information technology (health IT) .docxfaithxdunce63732
 
Assignment DetailsDiscuss the followingWhat were some of .docx
Assignment DetailsDiscuss the followingWhat were some of .docxAssignment DetailsDiscuss the followingWhat were some of .docx
Assignment DetailsDiscuss the followingWhat were some of .docxfaithxdunce63732
 

More from faithxdunce63732 (20)

Assignment DetailsScenario You are member of a prisoner revie.docx
Assignment DetailsScenario You are member of a prisoner revie.docxAssignment DetailsScenario You are member of a prisoner revie.docx
Assignment DetailsScenario You are member of a prisoner revie.docx
 
Assignment DetailsScenario You are an investigator for Child .docx
Assignment DetailsScenario You are an investigator for Child .docxAssignment DetailsScenario You are an investigator for Child .docx
Assignment DetailsScenario You are an investigator for Child .docx
 
Assignment DetailsScenario You are a new patrol officer in a .docx
Assignment DetailsScenario You are a new patrol officer in a .docxAssignment DetailsScenario You are a new patrol officer in a .docx
Assignment DetailsScenario You are a new patrol officer in a .docx
 
Assignment DetailsScenario Generally, we have considered sexual.docx
Assignment DetailsScenario Generally, we have considered sexual.docxAssignment DetailsScenario Generally, we have considered sexual.docx
Assignment DetailsScenario Generally, we have considered sexual.docx
 
Assignment DetailsPower’s on, Power’s Off!How convenient is.docx
Assignment DetailsPower’s on, Power’s Off!How convenient is.docxAssignment DetailsPower’s on, Power’s Off!How convenient is.docx
Assignment DetailsPower’s on, Power’s Off!How convenient is.docx
 
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docx
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docxAssignment DetailsIn 1908, playwright Israel Zangwill referred to .docx
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docx
 
Assignment DetailsPart IRespond to the following.docx
Assignment DetailsPart IRespond to the following.docxAssignment DetailsPart IRespond to the following.docx
Assignment DetailsPart IRespond to the following.docx
 
Assignment DetailsPlease discuss the following in your main post.docx
Assignment DetailsPlease discuss the following in your main post.docxAssignment DetailsPlease discuss the following in your main post.docx
Assignment DetailsPlease discuss the following in your main post.docx
 
Assignment DetailsPennsylvania was the leader in sentencing and .docx
Assignment DetailsPennsylvania was the leader in sentencing and .docxAssignment DetailsPennsylvania was the leader in sentencing and .docx
Assignment DetailsPennsylvania was the leader in sentencing and .docx
 
Assignment DetailsPart IRespond to the followingReview .docx
Assignment DetailsPart IRespond to the followingReview .docxAssignment DetailsPart IRespond to the followingReview .docx
Assignment DetailsPart IRespond to the followingReview .docx
 
Assignment DetailsPart IRespond to the following questio.docx
Assignment DetailsPart IRespond to the following questio.docxAssignment DetailsPart IRespond to the following questio.docx
Assignment DetailsPart IRespond to the following questio.docx
 
Assignment DetailsPart IRespond to the following questions.docx
Assignment DetailsPart IRespond to the following questions.docxAssignment DetailsPart IRespond to the following questions.docx
Assignment DetailsPart IRespond to the following questions.docx
 
Assignment DetailsOne thing that unites all humans—despite cultu.docx
Assignment DetailsOne thing that unites all humans—despite cultu.docxAssignment DetailsOne thing that unites all humans—despite cultu.docx
Assignment DetailsOne thing that unites all humans—despite cultu.docx
 
Assignment DetailsMN551Develop cooperative relationships with.docx
Assignment DetailsMN551Develop cooperative relationships with.docxAssignment DetailsMN551Develop cooperative relationships with.docx
Assignment DetailsMN551Develop cooperative relationships with.docx
 
Assignment DetailsInfluence ProcessesYou have been encourag.docx
Assignment DetailsInfluence ProcessesYou have been encourag.docxAssignment DetailsInfluence ProcessesYou have been encourag.docx
Assignment DetailsInfluence ProcessesYou have been encourag.docx
 
Assignment DetailsIn this assignment, you will identify and .docx
Assignment DetailsIn this assignment, you will identify and .docxAssignment DetailsIn this assignment, you will identify and .docx
Assignment DetailsIn this assignment, you will identify and .docx
 
Assignment DetailsFinancial statements are the primary means of .docx
Assignment DetailsFinancial statements are the primary means of .docxAssignment DetailsFinancial statements are the primary means of .docx
Assignment DetailsFinancial statements are the primary means of .docx
 
Assignment DetailsIn this assignment, you will identify a pr.docx
Assignment DetailsIn this assignment, you will identify a pr.docxAssignment DetailsIn this assignment, you will identify a pr.docx
Assignment DetailsIn this assignment, you will identify a pr.docx
 
Assignment DetailsHealth information technology (health IT) .docx
Assignment DetailsHealth information technology (health IT) .docxAssignment DetailsHealth information technology (health IT) .docx
Assignment DetailsHealth information technology (health IT) .docx
 
Assignment DetailsDiscuss the followingWhat were some of .docx
Assignment DetailsDiscuss the followingWhat were some of .docxAssignment DetailsDiscuss the followingWhat were some of .docx
Assignment DetailsDiscuss the followingWhat were some of .docx
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx

  • 1. CSE 220 Assignment 3 Hints and Tips Some hints for approaching this assignment is as follows: Approaching the assignment : General Overview It would be a good thing if before you start your assignment you try to decompose the problem you are trying to solve into small segments. Each segment can be then written and tested for any bugs or errors. Doing so will help you learn the true nature of functions and how effective they can be. The assignment requires that you read a string from either the stdin or a file and then count the frequency of words in it and display it to stdout or to a file. We can look at this in the following way : 1) Read an input from one of two sources a. stdin b. an input file 2) Find the frequency of words from input string 3) Write the words and their frequency to one of two ouputs a. Stdout b. An outputifle
  • 2. One way of solving the problem One way of approaching this code would be to create a structure which will hold a word and its frequency and then create an array of that structure to accommodate all the unique words in the input. So you would create a structure as follows: struct wordStorage { char word[50]; int count; }; Then when you want to create an array of that structure you would write it out as : struct wordStorage arr[size]; So we created an array to of size number of elements of the structure wordStorage created above. This array can then be used to keep track of all the unique words you come across in the input string and their frequencies. You can create arrays of this structure after you have defined the structure itself. You could then use the following prototypes in your code: 1. void decomposeToArray(char *para,char wordarr[1000][50]) This function takes in a string para and stores all the words in
  • 3. that string. You can modify it to return the array of words containing all the words using – char** decomposeToArray(char *para,char wordarr[1000][50]); 2. void frequencyOfWords(struct wordStorage *wordarr,char wordList[1000][50]) This function takes in a structure array in which element contains a word and its frequency and the array of words that you created using decomposeToArray(args). Instead of using a void function you can modify it so that it stores the words and their frequency as an array of the given structure and then returns the structure array. The prototype then becomes – struct wordStorage* frequencyOfWords(wordList[1000][50]) 3. void readFromFile(char *filename,char sentence[1000]) This function takes in the name of a file and a string to store all the contents of the file. You can use pass by reference to keep track of the string that is storing the string OR you could modify the function to read the name of a file and return a string using: char* readFromFile(char *filename) 4. void writeToFile(char *filename,struct wordStorage *wordarr);
  • 4. This function prints the contents of the structure array wordarr into the file whose name is specified by filename 5. void displayWords(struct wordStorage *wordarr); This functions writes the contents of the structure array ( containing words and their frequencies) on the standard output i.e. your display The prototypes mentioned above will then need to be linked in the main function depending on the arguments that are passed through the command line. For example : You can read a string from stdin and use decomposeToArray(args) to break your input string into a list of words. This list can be stored as a 2D character array and then sent to the function frequencyOfWords(list_you_got_from_decomposeToArray) and the function will return a structure array that consists of all the unique words in the string and their frequencies. [Note : frequencyOfWords() must have a structure array inside it in order to be able to return it. If you are using the void frequencyOfWords(struct wordStorage *wordarr,char wordList[1000][50]) variation, then you will need to use Pass By Reference to handle it.]
  • 5. Dealing with 2D Character arrays in C: 2D arrays in C can be a little overwhelming to understand especially when dealing with strings. It is important to understand the structure of the 2D character array while dealing with an array of strings. For example if you were to store a string in a single dimensional character array you could do it in the following ways : char *array=”This is a string in C!”; char array[]=”This is a string in C!”; char array[100]; strcpy(array,”This will also be a string!”); So you can see that a string in C is basically an array of characters. When dealing with an array of strings, you need to look at it like an array of strings or in our case an array of arrays ( where each string is an array!) So if we were to accept a sentence from the user and then store each word in an array, we would need a 2D array to do so. Think of it like this : char words[rows][cols]; Each row is a word and each column in a row is a character
  • 6. belonging to a certain word. So when you find a character in a word, you add it to the column of the present row ( the present word you are looking at). If a word is completed, then you go to the next row. The way to approach this would be to first accept the sentence from the user. Then try to decompose that sentence by selecting end of word markers ( or string delimiters). In the example which follows below, we assume that the space (‘ ‘) character is what signifies the end of a word. So if we had a string like : “This is a new sentence “, then we should be able to break it into 5 words where each word ends with a space character(‘ ‘). Now once we have set our word delimiters we need to check each character in the input string and decide whether a word is completely read or not. In order to do so, run a loop, extract each character into a dummy variable and check if it is your word delimiter ( here we use space only, you should consider punctuation marks and so on). If a character is not the word delimiter, add it to the word count 2D array along the second dimension( columns in the 2D array) .Otherwise if it is a word delimiter, then a word has been completely read from the input string – so we increment the counter on the 1st dimension ( rows of the 2D array used) of the 2D array to go to the next word slot. For example :
  • 7. char words[100][100]; // Assume that we are going to have a maximum of 100 words of size 100 characters each char sentence[1000]; //Assuming that the input string is just composed of 1000 characters char ch; // A dummy variable to act as a buffer for the input string int len,wc=0,c=0,i=0; printf("Enter a sentence:"); //Using the %[n]s we can force the scanf to ignore n characters. This allows us to input n scanf("%[n]s",&sentence); strcat(sentence," "); // I am assuming that every word in the string ends with a space len=strlen(sentence); //Calculate the length of the string input //The next part will show you how each word is read from the string and then stored inside a // 2D array for processing later for(i=0;i<len;i++) { ch=sentence[i]; //Read each character from the input string if(ch==' ') // If you have reached a space (‘ ‘)character , it implies a word is completely read { words[wc][c++]='0'; // Terminate each string with a ‘0’ character wc++; // We just finished adding a new word c=0; //Reset the counter which keeps track of the letter inside the word } else // If you read anything other than a ‘ ‘, add it as a letter to the present word {
  • 8. words[wc][c++]=ch; } } Reflection Requirement: Ready for a completely open-ended reflection response? If so, then go for it! If not, here are some suggestions to guide your thought process. Potential topics to address in your reflection: Why are “standards” so prevalent in education today? Why are “accountability” and “standards” the buzz words in many professions and society today? Isn’t it good to have standards in your life? So why is education any different? Some of you may have understood that the prevalent use of standards was just the way that schools are. If so, what was your reaction to Eisner’s view of the standards system in “The Centrality of Curriculum and the Function of Standards”? #include<stdio.h>
  • 9. #include<string.h> #include<stdlib.h> #include<ctype.h> int numWords; int numUniqWords; struct wordStorage { char word[50]; int count; }; /* You can modify the functions to return objects instead of using void and pass by reference */ /* This is your choice and depends on how you wish to code it */ void decomposeToArray(char *para,char wordarr[1000][50]); void frequencyOfWords(struct wordStorage *wordarr,char wordList[1000][50]);
  • 10. void readFromFile(char *filename,char sentence[1000]);; void writeToFile(char *filename,struct wordStorage *wordarr); void displayWords(struct wordStorage *wordarr); /* This function is optional and you can use it to create a robust program that can read and write from any of the sources. You adjust the read and write values and according to some set values ( eg 0=>STDIO and 1=>FILE) you call the required functions to process your input */ void executeCode(int read,int write,char readFile[100],char writeFile[100]); int main(int argc,char *argv[]) { int i,j; char readFile[100]; char writeFile[100]; int flag=0; // Checks for -h option. 1=FOUND , 0=NOT FOUND
  • 11. if(argc<=1) { // Fill code here when there are no options given i.e. the time when you read from STDIN and write to STDOUT } else if(argc>=2) { for(i=1;i<argc;i++) { if(strcmp(argv[i],"-h")==0) { printf("nRead English Language text and calculate word frequencies.n"); printf("nn"); printf("-h Display this help message.n"); printf("-f file Read text from given file.n"); printf("-o file Write program output to file.n"); printf("-v Display version info and
  • 12. exit.n"); flag=1; break; } } //Write code to link the functions and construct your program overall return 0; } void decomposeToArray(char *para,char wordarr[1000][50]) { // Fill your code here } void frequencyOfWords(struct wordStorage *wordarr,char wordList[1000][50]) { // Fill your code here
  • 13. } void readFromFile(char *filename,char sentence[1000]) { // Fill your code here } void writeToFile(char *filename,struct wordStorage *wordarr) { // Fill your code here } void displayWords(struct wordStorage *wordarr) { // Fill your code here }
  • 14. CSE220 Programming for Computer Engineering Assignment 3 CSE220 Page 1 Assignment 3 – CSE220 – Fall 2015 1. Instructions This is an individual assignment. Please start working on it as soon as possible and ask for help if you need it. Your project solution document must be uploaded to Blackboard by the assignment deadline. Section 6 de- scribes what to submit and by when; read it now. 2. Assignment Objectives 1. Write a basic C program. 2. Define and use local variables and global constants. 3. Define and use one-dimensional arrays. 4. Define and use C-string variables and C-string arrays. 5. Use flow of control constructs such as if-statements, for- loops, and while-loops. 6. Define and use C characters and Strings 7. Parse the command line for arguments and options. 8. Use functions from stdio.h to perform I/O with stdin/stdout and text files. 9. Understand the difference between declaration and definition. 10. Understand the difference between static and nonstatic functions, variables, and constants. 11. Use the GCC C compiler to compile a C program. Use the GDB debugger to debug a program. 3. Software Requirements
  • 15. Your project is to write a complete C program which will read several lines of text and prints a table indicating the number of occurrences of each different word in the text. The program should include the words in the table in the same order in which they appear in the text. For example, the lines To be, or not to be: that is the question: Whether ‘t is nobler in the mind to suffer Contains the word “to” three times, “be” two times, “or” once, and so on.. By default, the program will read input from stdin and send output to stdout. The -f file option will cause the program to read the input from the text file named file and the - o file option will cause the program to write the output to the file named file. The options are, -h Display a help message and exit. -f file Read input from the text file named file. -o file Output the results to the file named file. -v Display version info and exit. CSE220 Programming for Computer Engineering Assignment 3
  • 16. CSE220 Page 2 The -h Option Your program shall output the following help message when the -h option is specified, $ ./hw3 -h Usage: hw3 [option]... Read English language text and calculate word frequencies. Options: -h Display this help message and exit. -f file Read the text from “file”. -o file Write the results to “file.n -v Display version info and exit.n By default, text is read from stdin and the results are sent to stdout. The -h option has higher precedence than all of the other options, meaning that if it specified along with other options, the program shall act as if -h were the only option, $ ./hw3 -f foo -o prog -h -v The above help message is displayed The -v Option Your program shall output the following version information when the -v option is specified,
  • 17. $ ./hw3 -v hw3: version 1.0 (2015.8.13) Faye. Navabi <[email protected]> Replace my name and email address with your name and email address, and replace the date with the date you complete your program. If -h and -v are both specified on the command line, then -h shall take precedence, i.e., display the help message and exit. $ ./hw3 -v -h The above help message is displayed The -f and -o Options If -f or -o is specified without a file name, display an error message and terminate, CSE220 Programming for Computer Engineering Assignment 3 CSE220 Page 3 $ ./hw3 -f hw3: expecting argument following -f $ hw3 -o hw3: expecting argument following -o If the file specified with -f cannot be opened for reading (probably because it does not exist or the user made a typo), then display an error message, $ ./hw3 -f foo
  • 18. hw3: could not open foo If the file specified with -o cannot be opened for writing (probably because the file already exists and is read- only), then display an error message, $ ./hw3 -o /bin/date hw3: could not open /bin/date Default Input and Output By default, the program shall read the input from stdin and shall write the output to stdout, $ ./hw3 Parting is such sweet sorrow. The dog ate the cat. Goodbye. ^D The output is then displayed on the terminal window. 4.Submission When your project is complete, type make clean in your source code directory to clean your object files. the Then create a bzipped tarball named cse220-f15-hw3- lastname.tar.bz2, where lastname is your last name. $ make clean $ cd .. $ tar cvjf cse220-f15-hw3-lastname.tar.bz2 cse220-hw3 Submit this tarball to Blackboard using the assignment submission link before the deadline.