Difference: Test2 (1 vs. 2)

Revision 22017-10-24 - uli

Line: 1 to 1
 
META TOPICPARENT name="CourseExercises"

Mid-course test

Functions in C

Here is a little program calling an external function. It has 3 files:

Changed:
<
<
  • the main function called callMySin.c:

    callMySinC.png

  • the function implementation mysin.c

    mysinC.png

>
>
  • the main function called callMySin.c:

    callMySinC-1.png

  • the function implementation mysin.c

    mysinC-1.png

 
  • and the include file mysin.h

    mysinH.png

When you execute the program callMySin, what does it print?
Line: 50 to 50
 
<--/commentPlugin-->
Deleted:
<
<
META FILEATTACHMENT attachment="callMySinC.png" attr="" comment="" date="1508746212" name="callMySinC.png" path="callMySinC.png" size="14243" user="uli" version="1"
 
META FILEATTACHMENT attachment="compileErr.png" attr="" comment="" date="1508746212" name="compileErr.png" path="compileErr.png" size="37309" user="uli" version="1"
META FILEATTACHMENT attachment="Makefile.png" attr="" comment="" date="1508746212" name="Makefile.png" path="Makefile.png" size="9149" user="uli" version="1"
Deleted:
<
<
META FILEATTACHMENT attachment="mysinC.png" attr="" comment="" date="1508746212" name="mysinC.png" path="mysinC.png" size="13854" user="uli" version="1"
 
META FILEATTACHMENT attachment="mysinH.png" attr="" comment="" date="1508746212" name="mysinH.png" path="mysinH.png" size="2390" user="uli" version="1"
Added:
>
>
META FILEATTACHMENT attachment="mysinC-1.png" attr="" comment="" date="1508837147" name="mysinC-1.png" path="mysinC-1.png" size="14498" user="uli" version="1"
META FILEATTACHMENT attachment="callMySinC-1.png" attr="" comment="" date="1508837147" name="callMySinC-1.png" path="callMySinC-1.png" size="14469" user="uli" version="1"

Revision 12017-10-23 - uli

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="CourseExercises"

Mid-course test

Functions in C

Here is a little program calling an external function. It has 3 files:

  • the main function called callMySin.c:

    callMySinC.png

  • the function implementation mysin.c

    mysinC.png

  • and the include file mysin.h

    mysinH.png

When you execute the program callMySin, what does it print?

Here is how I try to compile it: What am I doing wrong?

compileErr.png

Can you write a Makefile to compile this program correctly?

Command line parameters:

I have a program named myProg which takes 4 parameters and which I execute as follows:

./myProg uli 65 ike 35

What is the value of:

  • argc

  • argv[0]

  • argv[5]

  • (argv[3])[1]

My program needs the second and forth parameter as integer values. As we have learned, the argv[x] however are strings. What do I have to do?

Write a piece of code that makes sure that the user enters exactly 4 parameters

How can I check if the first parameter is the string “uli” and the second one the string “ike”?

Makefiles

In the following Makefile which, builds the hello world program:

Makefile.png

which elements are

  • macros

  • targets

  • dependencies

What does $(RM) do?

What do $@ and $^ mean and, in the above Makefile example, into which values do these expand to?

-- Uli Raich - 2017-10-23

Comments

<--/commentPlugin-->

META FILEATTACHMENT attachment="callMySinC.png" attr="" comment="" date="1508746212" name="callMySinC.png" path="callMySinC.png" size="14243" user="uli" version="1"
META FILEATTACHMENT attachment="compileErr.png" attr="" comment="" date="1508746212" name="compileErr.png" path="compileErr.png" size="37309" user="uli" version="1"
META FILEATTACHMENT attachment="Makefile.png" attr="" comment="" date="1508746212" name="Makefile.png" path="Makefile.png" size="9149" user="uli" version="1"
META FILEATTACHMENT attachment="mysinC.png" attr="" comment="" date="1508746212" name="mysinC.png" path="mysinC.png" size="13854" user="uli" version="1"
META FILEATTACHMENT attachment="mysinH.png" attr="" comment="" date="1508746212" name="mysinH.png" path="mysinH.png" size="2390" user="uli" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback