Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Base 6 4 In this assignment, you will write a simple base 6 4 encoding utility to familiarize yourself with the basics of C programming.
Base
In this assignment, you will write a simple base encoding utility to familiarize yourself with the basics of C programming. You will be using, exclusively, a small subset of the C standard library to accomplish this task. You will practice:
Parsing commandline arguments
Using the standard io library features
Handling errors
Manipulating data and working with arrays
Learning Outcomes
How to write a C program to solve a problem? Module MLO
How can programs invoke OS services using system calls? Module MLO
How do you interact with the user in C programs? Module MLO
How are C programs transformed into an executable form? Module MLO
Specification
NAME
base Base encode data and print to standard output
SYNOPSIS
baseFILE
DESCRIPTION
Base encode FILE, or standard input, and output to standard output.
With no FILE, or if FILE is read from standard input.
Encoded lines are wrapped every characters.
The data are encoded according to the standard algorithm and standard base alphabet described in RFC
STDIN
The standard input shall be used only if no FILE operand is specified, or if the FILE operand is
STDOUT
The standard output shall contain the base encoded output, wrapped to characters.
STDERR
The standard error shall be used only for error reporting. All errors must be reported to standard error.
EXIT STATUS
if successful.
if an error occurs.
Additional Requirements
Your program may not use Variable Length Arrays VLAs which are declared with a nonconstant expression as the array size eg char inputn The compiler option Werrorvla will prevent compilation with VLAs.
Your program must compile against the c standard, using the compiler option stdc
In other words,
gcc stdcWerrorvla o base
The provided makefile compiles with the appropriate options, and you do not need to modify it
$ make B release
gcc stdcWall Werrorvla Werror Oc o buildreleasebaseo srcbasec
gcc o buildreleasebase buildreleasebaseo
$ make B debug
gcc stdcWall Werrorvla g c o builddebugbaseo srcbasec
gcc o builddebugbase builddebugbaseo
Gradescope will compile your program using its own copy of the makefile; you need only to upload your c source files and nothing else.
Additionally, your program must run in constant space complexity while accepting input of any arbitrary length. In other words, you may not dynamically allocate memory. The idea is that your program will process input in small chunks, until reaching end of input. Do not attempt to buffer the entire input before encoding it If found to violate this requirement, you will receive a
When exiting due to an error, your program must print an informative error message to the standard error stream, stderr and exit with a nonzero exit status. You are encouraged to use the convenience function errint exitval, char const fmt exposed by the header file, which both exits the program and prints an informative error message in a single operation. On the same note, you must not print to stderr and must exit with or EXITSUCCESS if you don't encounter any errors.
Your program must not have any memory leaks; since you are prohibited from dynamically allocating space for input, the only place you should worry about encountering a memory leak is with opened files. See the advice below for ensuring you meet this requirement.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started