{"id":312,"date":"2012-09-10T14:43:21","date_gmt":"2012-09-10T07:43:21","guid":{"rendered":"http:\/\/blog.kusumoto.co\/?p=312"},"modified":"2012-09-10T14:43:28","modified_gmt":"2012-09-10T07:43:28","slug":"quiz-it-structuring-data-file","status":"publish","type":"post","link":"https:\/\/oldblog.kusumotolab.com\/?p=312","title":{"rendered":"Quiz IT (Structuring data &#038; File)"},"content":{"rendered":"<ol>\n<li>\u0e08\u0e07\u0e40\u0e02\u0e35\u0e22\u0e19\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21<\/li>\n<\/ol>\n<p>1.1\u00a0 \u0e23\u0e31\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e19\u0e31\u0e01\u0e28\u0e36\u0e01\u0e29\u0e32\u0e0b\u0e36\u0e48\u0e07\u0e1b\u0e23\u0e30\u0e01\u0e2d\u0e1a\u0e14\u0e49\u0e27\u0e22 \u0e23\u0e2b\u0e31\u0e2a 7 \u0e15\u0e31\u0e27\u0e2d\u0e31\u0e01\u0e29\u0e23\u00a0 \u0e0a\u0e37\u0e48\u0e2d\u0e44\u0e21\u0e48\u0e40\u0e01\u0e34\u0e19 20 \u0e15\u0e31\u0e27\u0e2d\u0e31\u0e01\u0e29\u0e23 \u0e41\u0e25\u0e30 \u0e04\u0e30\u0e41\u0e19\u0e19\u0e27\u0e34\u0e0a\u0e32 Math\u00a0\u00a0 Eng\u00a0\u00a0 ComPro\u00a0 \u0e41\u0e25\u0e30\u0e27\u0e34\u0e0a\u0e32\u00a0 Bio\u00a0 \u0e40\u0e1b\u0e47\u0e19\u0e08\u0e33\u0e19\u0e27\u0e19\u0e40\u0e15\u0e47\u0e21 \u0e41\u0e25\u0e49\u0e27\u0e40\u0e02\u0e35\u0e22\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e25\u0e07\u0e41\u0e1f\u0e49\u0e21 student.txt \u0e08\u0e33\u0e19\u0e27\u0e19 3 \u0e04\u0e19<\/p>\n<p><a href=\"http:\/\/img.kusumoto.co\/show\/506\" target=\"_blank\"><img decoding=\"async\" src=\"http:\/\/img.kusumoto.co\/i\/oG.png\" alt=\"Host by img.kusumoto.co\" \/><\/a><\/p>\n<pre lang=\"c\">\r\n#include <stdio.h>\r\n#include <stdlib.h> \/\/use function 'exit' \r\n\/*\r\nCode By Weerayut Hongsa (Kusumoto)\r\nSoftware Engineering \r\nPrince of Songkla University\r\nPhuket Campus\r\nhttp:\/\/kusumoto.co\r\n*\/\r\n\r\n\/\/writedata.c\r\nstruct student {\r\n\tchar id[7];\r\n\tchar name[20];\r\n\tint math,eng,bio,compro;\r\n\tlong max_cred;\r\n};\r\nstruct student stu_rec;\r\nint numofcus = 3; \/\/Loop Construction\r\nFILE *fptr;\r\nvoid getstu(void);\r\nmain(void) {\r\n\t\/\/Open File for writing\r\n\tfptr = fopen(\"C:\\\\student.txt\", \"wb\");\r\n\tif (fptr == NULL) { \/\/Check File in part\r\n\t\tprintf(\"\\n Error open file\");\r\n\t\texit(1); \r\n\t}\r\n\tgetstu(); \/\/Run Function Input Data\r\n\tfclose(fptr); \/\/Close File\r\n\tprintf(\"\\n\");\r\n\treturn(0);\r\n}\r\nvoid getstu(void) {\r\n\tint i;\r\n\tfor(i=0; i<numofcus; i++) { \/\/Loop Input Method\r\n\t\tprintf(\"======== No. %d ==========\\n\",i+1);\r\n\t\tprintf(\"Student id :: \");\r\n\t\trewind(stdin);\r\n\t\tgets(stu_rec.id);\r\n\t\tprintf(\"Student Name :: \");\r\n\t\trewind(stdin);\r\n\t\tgets(stu_rec.name);\r\n\t\tprintf(\"Math score :: \");\r\n\t\tscanf(\"%d\", &#038;stu_rec.math);\r\n\t\tprintf(\"Eng score :: \");\r\n\t\tscanf(\"%d\", &#038;stu_rec.eng);\r\n\t\tprintf(\"Compro score :: \");\r\n\t\tscanf(\"%d\", &#038;stu_rec.compro);\r\n\t\tprintf(\"Bio score :: \");\r\n\t\tscanf(\"%d\", &#038;stu_rec.bio);\r\n\t\tfwrite(&#038;stu_rec, sizeof(struct student), 1, fptr);\r\n\t\tprintf(\"Writing Student id : %s Complete\\n\", stu_rec.id);\r\n\t}\r\n\t\r\n}<\/pre>\n<p>1.1\u00a0 \u0e2d\u0e48\u0e32\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e08\u0e32\u0e01\u0e41\u0e1f\u0e49\u0e21 student.txt \u0e17\u0e35\u0e48\u0e44\u0e14\u0e49\u0e08\u0e32\u0e01\u0e02\u0e49\u0e2d 2.1 \u0e02\u0e36\u0e49\u0e19\u0e21\u0e32\u0e41\u0e25\u0e49\u0e27\u0e41\u0e2a\u0e14\u0e07\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14\u00a0 \u0e1e\u0e23\u0e49\u0e2d\u0e21\u0e17\u0e31\u0e49\u0e07\u0e04\u0e30\u0e41\u0e19\u0e19\u0e40\u0e09\u0e25\u0e35\u0e48\u0e22 \u0e41\u0e15\u0e48\u0e25\u0e30\u0e04\u0e19 \u0e40\u0e21\u0e37\u0e48\u0e2d\u0e1e\u0e34\u0e21\u0e1e\u0e4c\u0e04\u0e23\u0e1a\u0e17\u0e38\u0e01\u0e04\u0e19 \u0e43\u0e2b\u0e49\u0e1e\u0e34\u0e21\u0e1e\u0e4c\u0e04\u0e30\u0e41\u0e19\u0e19\u0e40\u0e09\u0e25\u0e35\u0e48\u0e22\u0e02\u0e2d\u0e07\u0e41\u0e15\u0e48\u0e25\u0e30\u0e27\u0e34\u0e0a\u0e32\u0e43\u0e19\u0e1a\u0e23\u0e23\u0e17\u0e31\u0e14\u0e2a\u0e38\u0e14\u0e17\u0e49\u0e32\u0e22<\/p>\n<p><a href=\"http:\/\/img.kusumoto.co\/show\/507\" target=\"_blank\"><img decoding=\"async\" src=\"http:\/\/img.kusumoto.co\/i\/yj.png\" alt=\"Host by img.kusumoto.co\" \/><\/a><\/p>\n<pre lang=\"c\">\r\n#include <stdio.h>\r\n#include <stdlib.h> \/\/use function 'exit' \r\n\/*\r\nCode By Weerayut Hongsa (Kusumoto)\r\nSoftware Engineering \r\nPrince of Songkla University\r\nPhuket Campus\r\nhttp:\/\/kusumoto.co\r\n*\/\r\n\r\n\/\/readdata.c\r\nstruct student {\r\n\tchar id[7];\r\n\tchar name[20];\r\n\tint math,eng,bio,compro;\r\n\tlong max_cred;\r\n};\r\nstruct student stu_rec;\r\nint numofcus = 3; \/\/Loop Construction\r\nFILE *fptr;\r\nvoid readstu(void);\r\nmain(void) {\r\n\t\/\/Open File for reading\r\n\tfptr = fopen(\"C:\\\\student.txt\", \"rb\");\r\n\tif (fptr == NULL) { \/\/Check File in part\r\n\t\tprintf(\"\\n Error open file\");\r\n\t\texit(1); \r\n\t}\r\n\treadstu(); \/\/Run Function Ouput Data\r\n\tfclose(fptr); \/\/Close File\r\n\tprintf(\"\\n\");\r\n\treturn(0);\r\n}\r\nvoid readstu(void) {\r\n\tfloat a;\r\n\t\trewind(fptr);\r\n\t\tprintf(\"Reading from file: student.txt\\n\");\r\n\t\tprintf(\"\\nID\\tName\\t\\tMath\\tEng\\tCompro\\tBio\\tMean\");\r\n\t\tdo  {\r\n\t\t\tfread(&stu_rec, sizeof(struct student), 1, fptr);\r\n\t\t\tif (feof(fptr)) break;\r\n\t\t\ta = (stu_rec.math+stu_rec.eng+stu_rec.bio+stu_rec.compro)\/3;\r\n\t\t\tprintf(\"\\n%s\\t%s\\t%d\\t%d\\t%d\\t%d\\t%.2f\",stu_rec.id,stu_rec.name,stu_rec.math,stu_rec.eng,stu_rec.compro,stu_rec.bio,a);\r\n\t\t}while (!feof(fptr));\r\n\t\t\r\n\t\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0e08\u0e07\u0e40\u0e02\u0e35\u0e22\u0e19\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21 1.1\u00a0 \u0e23\u0e31\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e19\u0e31\u0e01\u0e28\u0e36\u0e01\u0e29\u0e32\u0e0b\u0e36\u0e48\u0e07\u0e1b\u0e23\u0e30\u0e01\u0e2d\u0e1a\u0e14\u0e49\u0e27\u0e22 \u0e23\u0e2b\u0e31\u0e2a 7 \u0e15\u0e31\u0e27\u0e2d\u0e31\u0e01\u0e29\u0e23\u00a0 \u0e0a\u0e37\u0e48\u0e2d\u0e44\u0e21\u0e48\u0e40\u0e01\u0e34\u0e19 20 \u0e15\u0e31\u0e27\u0e2d\u0e31\u0e01\u0e29\u0e23 \u0e41\u0e25\u0e30 \u0e04\u0e30\u0e41\u0e19\u0e19\u0e27\u0e34\u0e0a\u0e32 Math\u00a0\u00a0 Eng\u00a0\u00a0 ComPro\u00a0 \u0e41\u0e25\u0e30\u0e27\u0e34\u0e0a\u0e32\u00a0 Bio\u00a0 \u0e40\u0e1b\u0e47\u0e19\u0e08\u0e33\u0e19\u0e27\u0e19\u0e40\u0e15\u0e47\u0e21 \u0e41\u0e25\u0e49\u0e27\u0e40\u0e02\u0e35\u0e22\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e25\u0e07\u0e41\u0e1f\u0e49\u0e21 student.txt \u0e08\u0e33\u0e19\u0e27\u0e19 3 \u0e04\u0e19 #include #include \/\/use function &#8216;exit&#8217; \/* Code By Weerayut Hongsa (Kusumoto) Software Engineering Prince of Songkla University Phuket Campus http:\/\/kusumoto.co *\/ \/\/writedata.c struct student { char id[7]; char name[20]; int math,eng,bio,compro; long max_cred; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[43],"tags":[],"class_list":["post-312","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3OMEb-52","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=312"}],"version-history":[{"count":2,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/312\/revisions"}],"predecessor-version":[{"id":314,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/312\/revisions\/314"}],"wp:attachment":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}