From 0f12df574fae95f500d8a4c3e14c76754bece81a Mon Sep 17 00:00:00 2001 From: kirreen Date: Tue, 3 Dec 2024 15:35:07 +0100 Subject: [PATCH] fscanf wont work. will have to map the file to an array and parse it manually. --- 3/a.out | Bin 0 -> 18392 bytes 3/inputDemo | 1 + 3/main.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100755 3/a.out create mode 100644 3/inputDemo create mode 100644 3/main.c diff --git a/3/a.out b/3/a.out new file mode 100755 index 0000000000000000000000000000000000000000..607010197ec4f269fb6f1701365fd53210d05fef GIT binary patch literal 18392 zcmeHPdvH|Oc|T`YS6Z=pA|8@4)#4xrKUh5wLIPx#$HL0tA!BfZUzgSHU1^K7tL_5> z6B}aeq#Bisaht?(nAYjE?=+OCRs?#dkN0UQ6-R-0C)uYK&{>bVhy*;aYx`WwtuuFwN zadlv$V`|6l{larX6iCN-DdZg4qh+|LLcWWzQQ8Ur>X{e5a_qzB-#l26xpDcxx%3zB zJ{%(->Ic-^)3(TXx8@l=YsqOjn1GmtB3;F;yccD7w ztLH5A0k<>c_1Ny1M=wk>n~TN{nX!>WW+Iv#6^Zn?m4X@r8Y5dKXO2aaq)BGevA#Yt zk&Q)D3COV{Q8STDMMsmzEHR!*rg8~EC>r%1v18}JmaS%2uq(LM;kzAfox`o^7Usad zU1r?MSi{L|&dTiDwRJR|vi3!XMlCcmJeE%BKup_pUPmEt%;5N_z%eHEMq^ze2GMUi zE~w;hOIFiS_%L|VElMV9=?F<^d8v}UVqDALKm9eFMjmktG8LYecs@ATXzQo-yucZO7!UPYzf&cP5XKZQwm>+ zzVv))DACio%cVJFb5xJMgs`bh%NZzVpqznn2Fe*IXP}&c->MA!tp0cYD{}IhFEVMI zZxEUtYM>SEhJU|-)F0!Q))*{;qMQQCe;GTriBol^2EB-5?l z)q;}$l4QCyyLuKfwb%L6fr+;sk4*d|a`K()gZsjrh0Zr3r}}?@N{Wl`f&0%B!TQ!` z06{>f`X``?oHCv!(sv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)vMbJx_F@od^0iKgPT z-VRewHWyE(Oq#;cBwb+4p=?%T)oeU>##1W>U9DjapBdi0&HSHM?9E+4IJW}yFegMX zdvpxbF=#Gh(-Gz{ms*)|5lp3XR&Y3#4~}QBa50lRTA~`tC$S(k8P}@KTLxC=qQgSD zk3_R0A{alKLK8N{g;7}!V-`=QQ*#6pwv06zC4lC}M{^>m!VKoDBjDAj1T$$hMnP)? zm&oXtWsbywWywaE(M%?aKncM-DvpjNV`w#vy08nX2JFg^ei4kN$Hp){BUo!FKMY(n zHH>4SN$YP*@ns zc>X^LrY|{(v1?#F*Y{l)p6?@=*0Q6f?&J5bG~Q_@pdB?`sYNDk{Hrif{usY9V0$vX z*A|_<8~+9@rTD>s?aGw$TUvPhS@$ns@IbB30n+jNSpFXaw?E5Fe+*2037+5APOqlg zW{($Jnw1&<9t?Es=+oA@4|V>Rf;xvn$3GRu@i_h*I&xt=uMaP@leZA7Y~t)0&y-$5 zmE!q*?-h;jb&xj0IHn$eOYwn_?HA~Hjd%C+%Q|uWd}6xd=XxHx1^%KwaOjm|X<=L`bv2>f2m5Rk&tG>y or1ON22flvM?+C6GE8z7Fiijt +#include + +#define LINES 1000 + +int parse_numbers(char *mulString, int *a, int *b) +{ + int i = 4; + while (mulString[i] >= '0' && mulString[i] <= '9') { + *a = *a * 10 + mulString[i] - '0'; + i++; + } + i++; + while (mulString[i] >= '0' && mulString[i] <= '9') { + *b = *b * 10 + mulString[i] - '0'; + i++; + } + return 1; +} + +int main() +{ + int sum = 0; + char mulString[32]; + + FILE *input; + input = fopen("./inputDemo", "r"); + int a = 0; + int b = 0; + while (fscanf(input, "%d,%d", &a, &b)) { + sum += a * b; + } + printf("%d, %d\n", a, b); + printf("%d\n", sum); +}