Here is the source code of the 3 functions of mysin.
https://afnog.iotworkshop.africa/pub/Embedded_Systems/SolutionsToTest2/mysin.tar.gz
The mySin function calculated the sin function but this time takes the angles in degrees instead of taking it it radians as the sin function in the math library does. It converts degrees into radians and calls the math library sin function whose result it returns to the caller (callMySin)
The main routine simply calls mySin with an angle of 30°
This is the result when running callMySin:
My way of compiling did not work because I did not link the math library into the program (-lm is missing)
The Makefile is part of the mysin.tar.gz package
To check it the strings are "uli" and "ike", use the string compare function strcmp:
if (strcmp("uli",argv[1]==0) then we found the right string. Alternatively we can say: if (strcmp("uli",argv[1]) as the integer 0 is interpreted as the boolean "false".
CC, CFLAGS, RM, $@ and $^ are all macros
hello and clean are targets
hello.c is a dependency
$(RM) translates into rm -f which removes the listed files but does not print a warning message if one of the listed files does not exists.
$@ is the target and expands into hello
@^ is the dependency and expands into hello.c
I![]() |
Attachment | History | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|---|
![]() |
mySinRes.png | r1 | manage | 1.7 K | 2017-10-24 - 11:12 | UnknownUser | |
![]() |
hello.tar.gz | r1 | manage | 0.3 K | 2017-10-24 - 11:10 | UnknownUser | |
![]() |
mysin.tar.gz | r1 | manage | 0.5 K | 2017-10-24 - 11:10 | UnknownUser |