Uni Blog: Week 01
Last updated: 6 minutes ago
Intro
I was going to write this post as an Intro to C but on working on the post, C isn't much different from C++. At least not enough to run a C series of posts and a C++ series at the same time. So, I think I will make a university semester by semester blog series instead. Just recap on the materials that I learned and worked on throughout the week.
This semester I have four courses; Extreme Programming, Operating Systems, Project Management, and Data Communications. This is Week 1. The semester started on Wednesday, which means I've only had one class this week (Extreme Programming). I also found some homework from another class (Operating Systems). I am not looking forward to the OS course and Project Management courses because I am sure I have done them, but the university system says I need them.
Project Management
No classes this week and no homework that I can work on. This class is being taught by a professor that I have had before. This guy brings an amazing attitude and energy to the class. I am stoked to have him again. There is a requirement in the syllabus for Microsoft Projects. I built a windows VM that I can RDP into. I hope I won’t need to use it much; I prefer staying in the Linux ecosystem.
Operating Systems
No class this week. I was able to find some work for this one though. There is a group project available that I have completed by myself. The last question says that I need to learn C and use system calls within C to write a program that opens, reads, and writes to a file from keyboard input. This has been a bit harder than I expected it would be. I was going to write this programming as a blog post, as I mentioned in the intro.
This course requires an Ubuntu install, so I built an Ubuntu VM that I can remote and ssh into for the course work. Setting up the SSH reminds me I have a request to do a SSH tutorial, so that may be soon.
Here is the question and the code I came up with. I am looking forward to the first class to see if I am even in the realm of correctness.
/* Write a C program in which input is taken from the Keyboard and is then written onto a
non-existing file of title ”test.txt”. In other words, a program should be able to create a file with
title ”test.txt” and the contents taken from Keyboard should be written in this file.
Hint: You need to use an open() system call to get a file descriptor, and then use this file
descriptor in the write() system call. */
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
int main (void) {
// opening the file for writing. creating it if it doesnt exist
int fd = open("ass1_output.txt", O_RDWR | O_CREAT, 0644);
// printing the file descriptor to see if open works
printf("File Descriptor: %d\n", fd);
// create the char buffer
char buf[100];
// reading the file bite size
ssize_t buffer_size = read(fd, buf, sizeof(buf));
// Print buffer size
printf("File read %zd bytes.\n", buffer_size);
// creating a char string
char text[100];
// grabbing keyboard input
printf("please enter some text: ");
scanf("%s", text);
printf("You entered: %s \n", text);
// writing string to file with an extra line break
write(fd, text, strlen(text));
write(fd, "\n", 1);
// reading the file again to see if changed
buffer_size = read(fd, buf, sizeof(buf));
// printing again
printf("File read %zd bytes.\n", buffer_size);
// close file properly
close(fd);
return 0;
}
Data Communications
No class this week. This course scares me; I have heard that it's intense. A lot of information, technical knowledge, and math. We will see though.
Extreme Programming
This one had a class and no homework. This one I original thought they would be teaching about Extreme Programming as in the [programming paradigm] (https://www.geeksforgeeks.org/software-engineering/software-engineering-extreme-programming-xp/), but it is going to be about big data and using Python and mapreduce. I wasn't looking forward to the programming paradigm, but I am now much more excited about this course. I love data and databases.
She spoke a lot about distributed data processing and how to handle large amounts of data. We didn't really get into anything meaty and there is no homework available yet, but I am going to try to build a few things in Python to reacquaint myself.
Conclusion
The first week is over! Easy week.
If you want me to elaborate on anything, please message me on Discord, Mastodon, X, or email me. I’ll be happy to go into more detail one-on-one or to create more posts.
References
Sorry, I didn't keep track of my C web references for the code. I did primarily use "C Programming (Second Edition)" By K.N. King. My research showed that this was the best book for C beginners, and it has been good so far.
