Lab 3 - FL13 - ECE 198 JL - University of Illinois - Engineering Wiki

But inc luding thes e header files in y our program

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: uot; header. It provides pe func tions lik e s trc py (), s trc at(), s trlen() etc . Thes e func tions are us ed to c opy one s tring to another, c onc atenate two s trings and find the length of a s tring res pec tively . But, inc luding thes e header files in y our program is not enough. You have to tell the c ompiler (gc c in our c as e) to link the libraries to the objec t c ode that the c ompiler produc es . W ithout the needed library objec ts , the link er will produc e an error c omplaining about "undefined s y mbols " bec aus e it c an't find the implementation for a func tion that y ou us ed in y our c ode. If y ou us e a math func tion (provided in the math.h header file) y ou would have to give a -lm flag to the c ompiler s o that it k nows that it has to link the math library . Similarly , if y ou us e any s tandard C func tion in y our program (s uc h as "printf" or "s c anf", or s ome of the s tring func tions ), y ou have to us e the flag -lc. This will tell the c ompiler to link y our objec t c ode with the s tandard C library . By default gc c will link with the C library even if y ou don't tell it to, s o y ou c an get away with omitting "-lc ". However, in general, y ou s hould not rely on the c ompiler to implic itly do this for y ou. Ex plic itly telling the c ompiler what libraries y our program needs is c ons idered good prac tic e. Lab 3 Assignment Ty pe in the following program. Save it as lab3.c in lab3 s ubdirec tory . #nld <ti.> icue sdoh #eieFNS 1 dfn IIH itmi ( n an ) { itnm,nm,as n u1 u2 n; pit (Etrtoitgr:"; rnf "ne w nees ) saf(%%" &u1 &u2; cn "dd, nm, nm) pit (Mseyporm.\"; rnf "ytr rga..n) i ( = nm) f 0 = u2 { pit (ivldipt\"; rnf "nai nu!n) } es le { fr(n =nm /nm;as> FNS;as=as/2 o as u1 u2 n = IIH n n ) { pit (%\" as; rnf "dn, n) } } } rtr 0 eun ; Compile and run this program with the following s et of inputs : a) num1= 10000 and...
View Full Document

This document was uploaded on 03/22/2014.

Ask a homework question - tutors are online