Open your editor and choose the option for creating a new file. Paste the contents below into the file:
#include <stdio.h>
int main() {
return 0;
}
Save the contents as a file with the name hello.c
. Here's what it looks like in Code on macOS.
Open Filezilla. In the right side file explorer, navigate to where you saved the file in the previous section. Open the Site Manager and connect to linux.gl.umbc.edu
. Once you've established a connection, use the right side window to create a directory called cmsc104
(unless you already have one). Double click that directory to enter it, then create a directory called class4
. Double click the class4
directory. Then double click your hello.c
file to transfer it to the remote server. Do not disconnect or close Filezilla.
Here's what it looks like in macOS:
Use PuTTY (Windows) or Terminal/SSH (macOS) to log into the UMBC Linux server. Then do the following:
- Type
cd cmsc104/class4
and press enter to change to the directory where you uploadedhello.c
. - Type
ls
and press enter. You should seehello.c
as part of the directory listing. - Type
gcc hello.c
and press enter to compile the source file into a runnable program. - Type
ls
and press enter. You should now see a file calleda.out
in the list. This is your compiled program. - Type
./a.out
and press enter to run the program. You won't see any output and it will appear to have done nothing - this is fine.
Here's what the above steps look like in macOS:
Go back to your editor. Let's update the program to print something to screen. Add the line printf("Hello, World!\n");
just above the line with the word return
. Your program should now look like this:
#include <stdio.h>
int main()
{
printf("Hello, World!\n");
return 0;
}
In Filezilla, double click the hello.c
file. If prompted about overwriting the file, go ahead and overwrite it. Then return to your shell (PuTTY or Terminal) and rerun the commands to compile and run the program:
gcc hello.c
./a.out
This is what it looks like in macOS:
Try making some changes on your own to the program, save it and recompile/rerun on the remote system. Can you make it print a different message? How about another line of text? Something more complicated? If you get stuck you can always paste the original program and reupload it and try again. The point here is to get used to the workflow of making small changes to the program, one at a time, uploading them and then trying them out.