From 7f4670089ca7abc1802bccee4773a167fd27ed90 Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Fri, 31 Jul 2020 21:25:15 +0700 Subject: [PATCH] Add struct and its tests --- tests/run | 4 ++++ tests/work1 | Bin 0 -> 16568 bytes tests/work1.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100755 tests/run create mode 100755 tests/work1 create mode 100644 tests/work1.c diff --git a/tests/run b/tests/run new file mode 100755 index 0000000..d47ba96 --- /dev/null +++ b/tests/run @@ -0,0 +1,4 @@ +#!/bin/bash + +gcc work1.c -o work1 +./work1 \ No newline at end of file diff --git a/tests/work1 b/tests/work1 new file mode 100755 index 0000000000000000000000000000000000000000..38a430811c34d630f396ff2e7d763d19c40df43b GIT binary patch literal 16568 zcmeHOU2Gd!6+X6;CfjZuC$x*VrQ2cILJP!6yG@(Yzi|?$lO=6Kn?MnyQ^%gf2LA+m z+&>=ZlBLMnEmT5Ced7U;x(|qbEFjTTSsFk*WVHxYV$uGnt4-Nu@&2@m5Un}q&OPJt z#8qF=Y9HoGp7V3hcka1o?u_rX@BLnEc+l_j0T(~)1CrE`Dpb}Lpm&!LrLGrNfeMeo z23UcbCj6+PhN#6cP5G?~rmfO0fRu2TW&LHpiW12x5!fWIHOdhZC0wnjlC@|`Rx*W< zRZX~NVxb*Di=CGF;$92KRFmzENXj@82?r6n zVA-b%!n7jWW6JrYZqsK$`djd;D3PoZ0YzMElyf-prkNyOkp_yQ3QMMYgap8pabH24 zh*Q=-h;Z7E$oB4+m#~bVsq8LvrSe&$tC-JD;m#COy%WNk)o! zih<&zwg`9N&=_6;Xsk)Mf+ri+v46627Si*_secf^3Jp3M7?G}#{xIs52KIoxN?@NN zJ7Bty&Y6>->!i|)X1rkP*?2k!2Zo3G`t@y*ZIPY_VwZ1b%y0PP2}roXzN&Aiw;CxWc@yn*WKrki+e+o&Q(a*FD1 zy;iMO3BUDUL*v z`-@k0;(}pJ>+D9N%`64A@|!2uU!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yn#WGS0HgAj+LqorAAdMaP| z_Er(#;F0LTm>xScfDu~ZGG7NufqTo1afJLH2& zE#~!9JeSNEpbs5Jt7JN-mx=~m1N3A@FBqA8B5oSw%}gis=`_OhiDFT@7iW%i zee__zOcX?lXR>B|0;yTBXo@*JvSbvdA(G3RMkLxd)M>`2ATpIJMN;u%3L?ofIRsnO zELb%sjY2V<&(#S!)?r|A0!VH;V?snk9Wjm5$kPzOy1YnY#7N1To=PH?B@1EQeG9?- zw-RWE-s9PH0-MgGL%c*pE0#x00Yq>xW^sUthvNTmq3;uXbnv^wDm)+J^N^dQo(b7H z%V$uaxhUg#-o)qs6sIxr{9a*o4>I(QV0^`|q69e462w0L#qSZG=dz!zXm$tZu8a={ zQ~?aj2{zC3-FVA8z;0w{uFm*giSL#86Vh-6QtCUm&-3bj)R8IUFG>6*iRbkInutO^ zoaM_X&|IAHJpa2R@!THA&vs0YA)e;;EZg%$nIJ_r=8j*gVG0>CWjxO(6^ZYbhTJ~K z!~Oq`#P>-%UZ0FeJlheT)-Z1TcTq<ctzqBiC1h( zi;-$}4^O-B{Qaa#!%dtR>4)*`_J=M!&x=zXmIbd<+1?%h1&OztQB=!RsUwzvS2zBr zsH6Tfp6A($f=VoVEMi~X_@85q6VLPU6N&{{w2>CW_m9;yp9|tg4p)2L&gW{~_AE2~ z4PtTDVdHszU+F|87Phmbn#}q?Ud55_h)2i>@nV6FUWJx6>^S+$0xVT zXvwJhwWuLScG?wBb_w2^^AYq)>sVVos`F})ASfSl!>SJINcJChujIH@P8M=@N0y+Zey6*8<#@I3{lV{{Xt}LT&&6 literal 0 HcmV?d00001 diff --git a/tests/work1.c b/tests/work1.c new file mode 100644 index 0000000..53bd904 --- /dev/null +++ b/tests/work1.c @@ -0,0 +1,41 @@ +#include "stdio.h" +#include "string.h" + +struct person_tag +{ + char name[20]; + char id[10]; +}; + +struct course_tag +{ + char course_name[20]; + int no_of_units; + int marks[4]; + float avg; +}; + +struct student_tag +{ + struct person_tag student_info; + struct course_tag course_info; + struct student_tag *next; +}; + +int main() +{ + + struct person_tag person, person2 = {"Chea", "4567892"}, *personPtr; + + // strcpy style + strcpy(person.id, "2345678"); + strcpy(person.name, "Sambo"); + + personPtr = &person; + + printf("Hello, %s \n", person.name); + printf("Hello, %s \n", person2.name); + printf("Hello Ptr, %s \n", personPtr->name); + + return 0; +} \ No newline at end of file