首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
COMP-206程序讲解、辅导C/C++程序设计、Software编程语言调试 讲解R语言编程|辅导Python程序
项目预算:
开发周期:
发布时间:
要求地区:
School of Computer Science, McGill University
COMP-206 Introduction to Software Systems, Winter 2020
Mini Assignment 5: C Programming - File IO
Due Date Nov 17th, 23:55
This is an individual assignment. You need to solve these questions on your own. If you have
questions, post them on Piazza, but do not post major parts of the assignment code. Though small
parts of code are acceptable, we do not want you sharing your solutions (or large parts of them) on
Piazza. If your question cannot be answered without sharing significant amounts of code, please make
a private question on Piazza or utilize TA/Instructors office hours. Please ensure to check “Mini 5
general clarifications” pinned post in Piazza before you post a new question. It might have been
already clarified there if it is a popular question.
Late penalty is -5% per day. Even if you are late only by a few minutes it will be rounded up to
a day. Maximum of 2 late days are allowed.
You MUST use mimi.cs.mcgill.ca to create the solution to this assignment. You must not use your
Mac command-line, Windows command-line, nor a Linux distro installed locally on your laptop. You can access
mimi.cs.mcgill.ca from your personal computer using ssh or putty as seen in class and in Lab A.
DO NOT edit files on your laptop; use vim on mimi. If TAs are not able to compile your code on
mimi as-is, you will get 0 points.
Questions in this assignment require you to turn in one C program and one shell script. Instructors/TAs upon
their discretion may ask you to demonstrate/explain your solution. No points are awarded for commands that
do not execute at all or programs that do not compile on mimi. (Commands/programs that execute/compile,
but provide incorrect behavior/output will be given partial marks.). All questions are graded proportionally. This
means that if 40% of the question is correct, you will receive 40% of the grade. Any exceptions are mentioned at the
appropriate part of the problem description.
Please read through the entire assignment before you start working on it. You can lose up to 3
points for not following the instructions.
Unless otherwise stated, all the names of the scripts and programs that you write, commands, options, input
arguments, etc. are case-sensitive.
Total Points: 20
Ex. 1 — A Data Analytics Program(16 Points)
As you saw in assignment 3, online platforms can track users easily and study and analyze user behaviour. Such
data analytics are also relevant with remote delivery of exams. In this assignment, you will analyze an user event file
(data.csv) for such an exam generated from mycourses (anonymised) to look for students who could have possibly
collaborated.
The CSV file has a header, and as can be seen below, contains 6 fields in each line which details the user events. The
fields have consistent layout, and the file is structured in such a way that all the events related to a particular user
is adjacent to each other (i.e. the events associated to a given user are always in contiguous lines in the file).
User, Attempt, Date, Time, Event, IP Address
Raveena Mullen,1,"Oct 9, 2020",4:54 AM,Quiz Entry,157.149.164.98
Raveena Mullen,1,"Oct 9, 2020",4:54 AM,Response to Question 1 Saved,157.149.164.98
1
Raveena Mullen,1,"Oct 9, 2020",4:55 AM,Response to Question 1 Saved,157.149.164.98
...
Orla Stout,1,"Oct 9, 2020",6:49 AM,Response to Question 6 Saved,51.82.149.197
Orla Stout,1,"Oct 9, 2020",6:53 AM,Response to Question 6 Saved,51.82.149.197
Orla Stout,1,"Oct 9, 2020",6:53 AM,Response to Question 6 Saved,51.82.149.197
...
Hashir Palmer,1,"Oct 9, 2020",4:51 AM,Response to Question 19 Saved,121.242.142.46
Hashir Palmer,1,"Oct 9, 2020",4:52 AM,Response to Question 19 Saved,121.242.142.46
...
One of the techniques to look for collaboration in the above data is to analyze the IP address of the events. IP
addresses are good indicators of proximity. In this assignment, for simplification, we will define “proximity” as two
users sharing the same IP address. In other words, two students will be considered to have collaborated if they have
the same IP address. We will not go into the networking details of this data, as it is beyond the scope of this course
- but consider COMP 535, COMP 512 if it piques your curiosity.
You can make the following assumptions (use this to simplify your code logic).
•The maximum length of any line in the file will not exceed 200 characters.
•The maximum length of a user’s name will not exceed 100 characters.
•The maximum length of an IP address will not exceed 50 characters.
•A user will not be associated with more than one IP address.
•No two students have the same name.
•Events in the file are grouped by user. This means that all of user’s events will appear one after another in the
file. The CSV data file is not sorted though.
You will write a program, report.c that accepts three arguments.
, "
",
,
where
is the name of the data file containing the events "
" is the name of the student
we are searching for and
is a text file to which the names of the collaborators will be written.
1.Use vim to create a C program source file report.c . All of your source code logic should be contained in this
file. You may split your program logic across multiple functions if you would like to (recommended).
2.(1 Points) The source code file should include a comment section at the beginning that describes its purpose
(couple of lines), the author (your name), your department, a small “history” section indicating what changes
you did on what date. (Similar to the previous assignment). The code should be properly indented for readability
as well as contain any additional comments required to understand the program logic.
3.(1 Point) The source code should be compilable by (exactly) using the command gcc -o report report.c
4.(1 Point) Compilation should not produce any warnings!
5.(1 Point) All error situations (described below) should result in error code 1 when the program terminates
and 0 otherwise. No points for this, if this requirement is violated even for any one test case.
6.(1 Point) All the error messages (described below) should be printed to standard error. Again, no points for
this, if this is violated for any situation.
7.(1 Point) Your program should accept the three arguments mentioned above. If the user does not pass sufficient
arguments, or pass incorrect number of arguments, you should display an error message and terminate with
error.
$ ./report data.csv
Usage ./report
"
"
$ echo $?
1
$
8.(1 Point) Make sure that the data file can be read. If not, display an error message and terminate.
$ ./report nosuchdata.csv "Jane Doe" rpt.txt
Error, unable to open csv file nosuchdata.csv
$ echo $?
2
1
$
9.(1 Point) Make sure that the user to search for is present in the data file. If not, display an error message and
terminate.
$ ./report data.csv "Jane Doe" rpt.txt
Error, unable to locate Jane Doe
$ echo $?
1
$
10.(1 Point) If all of the above checks have succeeded, then make sure that the output file can be created. If not,
display an error message and terminate.
$ ./report data.csv "Markus Bender" rpt.txt
Error, unable to open the output file rpt.txt
$ echo $?
1
$
11.(1 Point) If the program cannot find any collaborators for a given student, then simply write the following
contents into the output report file.
$ ./report data.csv "Markus Bender" rpt.txt
$ echo $?
0
$ cat rpt.txt
No collaborators found for Markus Bender
$
12.(1 Point) Your program should work for both relative and absolute paths (for both the input CSV data file
and the output report file).
13.(4 Points) If the program finds any collaborators for the student, then include their names in the output report
file (one name per line).
$ ./report data.csv "Adaline Murphy" rpt.txt
$ echo $?
0
$ cat rpt.txt
Huma Foster
Abdullah Allen
$
Do not include the original student name, only the collaborators. The output student names in the report can
be in any order.
14.(0 Points) Make sure that the output report file does not have any duplicate student names.(I.e., do not repeat
a student name in the output). -2 Points if any test case produces duplicates in the output.
15.(1 Point) Make sure to overwrite any existing output report file if it already exists.
16.(0 Points) If your program crashes/aborts for any test case due to bug in your logic, an additional -2 Points
will be deducted.
17.(0 Points) This exercise’s solution need to be completely implemented using a C Program. You may not use
other Unix utilities like sed, awk, etc. Violating this will be an automatic 0. You are free to use any C library
functions and header files that you need to work on this, subject to clause 3.
3
Ex. 2 — A mini tester script(4 Points)
There is no mini tester supplied with this assignment. Using the Unix scripting skills you have picked up so far, you
can write a simple mini tester, mini5tester.sh for your program.
At a minimum you should include the above test cases (need not be exact, but similar in principle and objectives).
Your tester does not have to automatically decide whether a test case is passed or failed, it just needs to provide
enough output for a person who is running it to make that judgement without having to read code (like how the
program was invoked, what did it produce, what was the return code of the program, etc.). You can look at the past
mini tester scripts for some inspiration, but it need not be very complicated and thorough. This script is not going
to be as rigorously evaluated as the C program.
You can assume that the data.csv and the report.c files are in the current directory. You can also store the output
report files in the same directory. Can you think of way you can still test for absolute and relative paths?
HINT
For a basic solution, I suggest your separate out your logic into different functions. For example there could be a
function to parse a character array containing a line in the log file and produce the name of the student and ip address
associated with that line. Another function can check if the student’s name exists in the data file. Yet another
function can be used to go through the data file and produce the names of students who might have collaborated.
You are not obliged to follow this approach.
I also recommend that you explore the C library function strtok.
A possible template to start your work, and divide the tasks into separate functions is given below. This is not
yet a compilable code. You can use this as your base if you would like to.
struct logrecord
{
char name[100];
char IPAddress[50];
};
struct logrecord readLog(char* logline)
{
// parse a character array that contains an line from the log
// and return a structure that contains the fileds of interest to us.
}
bool checkNameExists(FILE* csvfile, char* name, char* ip)
{
// Read through the CSV data file, keep looking for the name.
// If found, store the IP address associated with the name
// to the variable ip and return success.
// Is bool a valid data type in C? How do you indicate true/false concept in C?
}
bool findCollaborators(char* sname, char *sip, FILE* csvfile, FILE* rptfile)
{
// Go through the CSV data file
// look for collaborators of sname by looking for entries with the same ip as sip
// if any collaborators are found, write it to the output report file.
}
int main(int argc, char* argv[])
{
// Do any basic checks, "duct-tape" your full program logic using the above functions,
4
// any house-keeping, etc.
}
WHAT TO HAND IN
Turn in the C program source code report.c, and the shell script mini5tester.sh named properly. You may zip/tar
the file if necessary. The file(s) must be uploaded to mycourses. DO NOT turn in the executable report. TAs will
compile your C program on their own as indicated in the problem descriptions above. If you zip/tar your submission,
you are responsible to download your submission from mycourses and verify that it is not corrupted (happens when
students make an error in their zip/tar command). There will be no excuses for corrupted files.
MISC. INFORMATION
There is no tester script that is provided with the assignment, as you will be writing a simple one yourself. TAs will
have their own tester script, however they will use the exact same data file, and same syntax for test cases as given
in the above examples. They may however, test using different names than the ones given in the above examples.
** Important ** If your program “hangs” / is stuck while testing (should not take more than 30s for a given
test case) then you will loose points associated with it - This is already very far from the time any reasonable program
should take to execute this task.
FOOD FOR THOUGHT!
• Data analytics systems often produce an output file that is more sophisticated than a simple text file (like a
PDF, an image of a chart, etc.). Can your program check if the extension of the output file given as argument
is html and produce the output as an html file (write the names in an HTML table)? This is very easy to
perform and do not require any extra libraries - you just need to play around with what you write to the output
file and include the required HTML tags in it - try it!
5
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!