[ CPS 125 / Teaching Assistant ] Reading File to Arrays

Please note that this post is for the students in the course in CPS 125 (CPS125 : Digital Computation and Programming), the reason for making these posts are 1) aid the students in the course, 2) to improve my communication skills via writing.

Disclaimer: I was not instructed to write these posts, additionally, I won’t provide any materials directly related to solutions for the assignments.

Introduction

https://gph.is/1Z8bw8m

Hello again! Let’s get right into the user input use cases!

Have a Data file with numbers

This part is simple, just have a text file with a couple of numbers here and there.

Next, we can use the while loop and pointer variable to read until the end of the file.

Great, we have created a simple array to store the numbers that we have just read. Now let's try to find the max values.

That was super easy, right? Now try to find the min value of the array. Finally, let's create another array with every element in the array being 4 times larger.

That’s all folks!

Reference

  1. How to read until end of file C, f., & Naired, R. (2017). How to read until end of file C, fscanf. Stack Overflow. Retrieved 18 March 2019, from https://stackoverflow.com/questions/43098701/how-to-read-until-end-of-file-c-fscanf

https://jaedukseo.me I love to make my own notes my guy, let's get LIT with KNOWLEDGE in my GARAGE

https://jaedukseo.me I love to make my own notes my guy, let's get LIT with KNOWLEDGE in my GARAGE