Tags:
create new tag
view all tags

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-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?

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

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng Makefile.png r1 manage 8.9 K 2017-10-23 - 08:10 UnknownUser  
PNGpng callMySinC-1.png r1 manage 14.1 K 2017-10-24 - 09:25 UnknownUser  
PNGpng compileErr.png r1 manage 36.4 K 2017-10-23 - 08:10 UnknownUser  
PNGpng mysinC-1.png r1 manage 14.2 K 2017-10-24 - 09:25 UnknownUser  
PNGpng mysinH.png r1 manage 2.3 K 2017-10-23 - 08:10 UnknownUser  
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2017-10-24 - uli
 
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