{"id":842,"date":"2014-09-01T00:01:13","date_gmt":"2014-09-01T07:01:13","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=842"},"modified":"2014-08-16T08:10:30","modified_gmt":"2014-08-16T15:10:30","slug":"hone-your-disk-drive-c","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=842","title":{"rendered":"Hone Your Disk Drive C"},"content":{"rendered":"<p>Often times the problems you&#8217;ll encounter in C involve interface with something else. You&#8217;ll need to code directions for an operating system or interact with data that already exists or is output from some function. In this month&#8217;s exercise, you get to test-run those skills.<br \/>\n<!--more--><br \/>\nAs an example, I&#8217;ve created a data file. Your job is to write code that properly reads the data from that file, and then outputs the data all formatted and pretty. If you&#8217;ve read my C programming books on file I\/O, then this should be a relatively simple exercise, although it&#8217;s always good to practice.<\/p>\n<p>The chunk of data has a format. In this case here are the &#8220;docs&#8221; for the format:<\/p>\n<ul>\n<li>Node number (<em>long int<\/em>)<\/li>\n<li>Gateway (20 character string)<\/li>\n<li>Access Time (<em>time_t<\/em> value)<\/li>\n<\/ul>\n<p>The name of the data file is <code><a href=\"http:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/0914.dat\">0914.dat<\/a><\/code> and you can download it by right-clicking that link. I can promise you that the file isn&#8217;t malware, although that may not stop your computer&#8217;s anti-virus software from getting all freaky. The file is only 40 bytes long, and I don&#8217;t think any clever Bad Guy could shove malware into something that teensy.<\/p>\n<p>If you read the data properly, the output lists these items:<\/p>\n<pre><code> Node number: 98255171\r\n     Gateway: wambooli.com\r\n Access Time: Mon Sep  1 16:46:11 2014<\/code><\/pre>\n<p>Please attempt to code your own solution before you peek at mine. Keep in mind that my solution is only one way to solve the problem; the C language is flexible enough that anyone can devise a proper (or improper) solution.<\/p>\n<p><a href=\"http:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2014\/09\/09exercise.c\">Exercise Solution<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Code a program that reads in a formatted chunk of data. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=842\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-842","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=842"}],"version-history":[{"count":9,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/842\/revisions"}],"predecessor-version":[{"id":937,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/842\/revisions\/937"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}