There are marks for completing lab exercises.
BUT it is highly recommended to attend your lectures, tutorials and labs to get the most out of the course
They can help you with anything related to using CSE's computers.
For help with accounts, passwords & printing, etc. contact UNSW central IT
Your tutor and/or assistant tutor may only be able to provide limited help during your lab times.
And for access to Lecture Recordings.
A link is avalible on WebCMS.
Operating systems on phones in your tut room might include Android, IOS (Apple), Windows.
CSE's lab computers and servers run Linux (Debian 5.10 (`$ uname -a`)).
They are part of the operating system's list of applications. The operating system is a more low-level, non graphical part of the computer. Nearly everything you see and understand in a computer is just the application layer built on top of an operating system. And this operating system allows all applications to abstract away the underlying hardware and devices that your software is running on.
Files for CSE users are kept on disks connected to servers in K17.
COMP1911 students will need to store C programs in files. They might also need to store, for example, input data for these C programs, machine code produced by compiling these C programs. These will all be separate files of different types.
Changing the file extension does not change the file itself or it's contents. You can manually change a file extension or remove it altogether and still manually open it in your program of choice.
dcc stuff.c -o stuff ./stuffOr if you were not on a cse machine or cse's vlab you could use gcc with these flags
gcc -Wall -Werror -O stuff.c -o stuff ./stuff
With gcc it is advised to run with the flags -Wall -Werror and -O to give more help with compile errors. dcc already does that for us anyway but is even more helpful. Note: when we test and mark your programs at uni we use dcc, so always make sure any code you submit compiles using dcc and runs on the cse machines/server.
The machine code file produced by gcc or dcc (a.out by default) is an example of an non-text file.
Over 20 editors are installed on CSE systems. A simple one named gedit is recommended for COMP1911 students.
However, gedit only works on systems with a GUI. If you are interacting with command line only then common ones used are vim and nano
COMP1911 students need machine code so that can execute the programs they write.
COMP1911 students obtain machine code by creating a C program then using dcc
or gcc
to translate it to machine code.
They keep the machine code in files. If you don't specify a file dcc and gcc put the
machine code in a file named a.out
.
mkdir lab02
creates a directory named lab02
in the current directory.
Discuss the following features of the sample program from lectures:
// Author: Hayden Smith (hsmith@unsw.edu.au) // Date created: February 2019 // My first C program #include <stdio.h> int main (void) { printf ("COMP1911 is my favourite computing course!\n"); return 0; }
\n
An example of a comment is a header comment. You should make sure you have a header comment with your name, date and the purpose of your program at the top of every program you write.
Comments can also be added throughout your code to make it easier for a human to understand your program
White space is required between C language keywords. For instance you can't have intmain without any intermediate space. Statements are placed on separate lines. Additional blanks lines can be inserted to enhance readability (ie. between printf and return). The closing brace } in this example is aligned beneath the type declaration (int) for the main function, to clearly denote the end of the function block.
face0.c
, that behaves as follows:
./face0 ~ ~ 0 0 o -
face0.c
#include <stdio.h> int main(void) { printf("~ ~\n"); printf("0 0\n"); printf(" o\n"); printf(" -\n"); return 0; }
dcc -o face face.cHow could we modify it to make a program,
face1.c
, look like this instead?
./face1 ~ ~ 0 0 o \_/
face1.c
#include <stdio.h> int main(void) { printf("~ ~\n"); printf("0 0\n"); printf(" o\n"); printf(" \\_/\n"); return 0; }