/
Reference Card ANSI Program StructureF unctions typ fnc typ function declarations typ Reference Card ANSI Program StructureF unctions typ fnc typ function declarations typ

Reference Card ANSI Program StructureF unctions typ fnc typ function declarations typ - PDF document

luanne-stotts
luanne-stotts . @luanne-stotts
Follow
469 views
Uploaded On 2014-12-01

Reference Card ANSI Program StructureF unctions typ fnc typ function declarations typ - PPT Presentation

Silv erman ermissions on bac k v13 Constan ts long su64259x or 64258oat su64259x or exp onen tial form ctal pre64257x zero hexadecimal pre64257x zeroex 0x or 0X haracter constan c har ctal hex a x hh newline cr tab bac kspace n r t b sp ecial hara ID: 19350

Silv erman ermissions

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "Reference Card ANSI Program StructureF u..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

CReferenceCard(ANSI)ProgramStructure/Functionstypefnc(type1,:::)functiondeclarationstypenameexternalvariabledeclarationsmain(){mainroutinedeclarationslocalvariabledeclarationsstatements}typefnc(arg1,:::){functionde nitiondeclarationslocalvariabledeclarationsstatementsreturnvalue;}/**/commentsmain(intargc,char*argv[])mainwithargsexit(arg)terminateexecutionCPreprocessorincludelibrary le#include lename�includeuser le#include" lename"replacementtext#definenametextreplacementmacro#definename(var)textExample.#definemax(A,B)�((A)(B)?(A):(B))unde ne#undefnamequotedstringinreplace#concatenateargsandrescan structurememberoperatorname.memberstructurepointerpointer�-memberincrement,decrement++,--plus,minus,logicalnot,bitwisenot+,-,!,~indirectionviapointer,addressofobject*pointer,&namecastexpressiontotype(type)exprsizeofanobjectsizeofmultiply,divide,modulus(remainder)*,/,%add,subtract+,-left,rightshift[bitops]&#x,000;&#x,000;comparisons&#x,000;,&#x,000;=,comparisons==,!=bitwiseand&bitwiseexclusiveor^bitwiseor(incl)|logicaland&&logicalor conditionalexpressionexpr1?expr2:expr3assignmentoperators+=,-=,*=,:::expressionevaluationseparator,Unaryoperators,conditionalexpressionandassignmentoper-atorsgrouprighttoleft;allothersgrouplefttoright.FlowofControlstatementterminator;blockdelimeters{}exitfromswitch,while,do,forbreaknextiterationofwhile,do,forcontinuegotogotolabellabellabel:returnvaluefromfunctionreturnexprFlowConstructionsifstatementif(expr)statementelseif(expr)statementelsestatementwhilestatementwhile(expr)statementforstatementfor(expr CReferenceCard(ANSI)Input/Output&#xstdi;&#xo.h0;StandardI/Ostandardinputstreamstdinstandardoutputstreamstdoutstandarderrorstreamstderrendof leEOFgetacharactergetchar()printacharacterputchar(chr)printformatteddataprintf("format",arg1,:::)printtostringssprintf(s,"format",arg1,:::)readformatteddatascanf("format",&name1,:::)readfromstringssscanf(s,"format",&name1,:::)readlinetostrings(maxchars)gets(s,max)printstringsputs(s)FileI/Odeclare lepointerFILE*fppointertonamed lefopen("name","mode")modes:r(read),w(write),a(append)getacharactergetc(fp)writeacharacterputc(chr,fp)writeto lefprintf(fp,"format",arg1,:::)readfrom lefscanf(fp,"format",arg1,:::)close lefclose(fp)non-zeroiferrorferror(fp)non-zeroifEOFfeof(fp)readlinetostrings(maxchars)fgets(s,max,fp)writestringsfputs(s,fp)CodesforFormattedI/O:"%-+0w:pmc"-leftjustify+printwithsignspaceprintspaceifnosign0padwithleadingzeroswmin eldwidthpprecisionmconversioncharacter:hshort,llong,Llongdoublecconversioncharacter:d,iintegeruunsignedcsinglecharscharstringfdoublee,Eexponentialooctalx,Xhexadecimalppointernnumberofcharswritteng,Gsameasfore,EdependingonexponentVariableArgumentLists&#xstda;&#xrg.h;declarationofpointertoargumentsva_listname;initializationofargumentpointerva_start(name,lastarg)lastargislastnamedparameterofthefunctionaccessnextunamedarg,updatepointerva_arg(name,type)callbeforeexitingfunctionva_end(name)StandardUtilityFunctions&#xstdl;&#xib.h;absolutevalueofintnabs(n)absolutevalueoflongnlabs(n)quotientandremainderofintsn,ddiv(n,d)retursnstructurewithdiv_t.quotanddiv_t.remquotientandremainderoflongsn,dldiv(n,d)returnsstructurewithldiv_t.quotandldiv_t.rempseudo-randominteger[0,RAND_MAX]rand()setrandomseedtonsrand(n)terminateprogramexecutionexit(status)passstringstosystemforexecutionsystem(s)Conversionsconvertstringstodoubleatof(s)convertstringstointegeratoi(s)convertstringstolongatol(s)convertpre xofstodoublestrtod(s,endp)convertpre xofs(baseb)tolongstrtol(s,endp,b)same,butunsignedlongstrtoul(s,endp,b)StorageAllocationallocatestoragemalloc(size),calloc(nobj,size)changesizeofobjectrealloc(pts,size)deallocatespacefree(ptr)ArrayFunctionssearcharrayforkeybsearch(key,array,n,size,cmp())sortarrayascendingorderqsort(array,n,size,cmp())TimeandDateFunctions&#xtime;&#x.h00;processortimeusedbyprogramclock()Example.clock()/CLOCKS_PER_SECistimeinsecondscurrentcalendartimetime()time2-time1inseconds(double)difftime(time2,time1)arithmetictypesrepresentingtimesclock_t,time_tstructuretypeforcalendartimecompstmtm_secsecondsafterminutetm_minminutesafterhourtm_hourhourssincemidnighttm_mdaydayofmonthtm_monmonthssinceJanuarytm_yearyearssince1900tm_wdaydayssinceSundaytm_ydaydayssinceJanuary1tm_isdstDaylightSavingsTime\ragconvertlocaltimetocalendartimemktime(tp)converttimeintptostringasctime(tp)convertcalendartimeintptolocaltimectime(tp)convertcalendartimetoGMTgmtime(tp)convertcalendartimetolocaltimelocaltime(tp)formatdateandtimeinfostrftime(s,smax,"format",tp)tpisapointertoastructureoftypetmMathematicalFunctions&#xmath;&#x.h00;Argumentsandreturnedvaluesaredoubletrigfunctionssin(x),cos(x),tan(x)inversetrigfunctionsasin(x),acos(x),atan(x)arctan(y=x)atan2(y,x)hyperbolictrigfunctionssinh(x),cosh(x),tanh(x)exponentials&logsexp(x),log(x),log10(x)exponentials&logs(2power)ldexp(x,n),frexp(x,*e)division&remaindermodf(x,*ip),fmod(x,y)powerspow(x,y),sqrt(x)roundingceil(x),floor(x),fabs(x)IntegerTypeLimits&#xlimi;&#xts.h;Thenumbersgiveninparenthesesaretypicalvaluesfortheconstantsona32-bitUnixsystem.CHAR_BITbitsinchar(8)CHAR_MAXmaxvalueofchar(127or255)CHAR_MINminvalueofchar(128or0)INT_MAXmaxvalueofint(+32,767)INT_MINminvalueofint(32,768)LONG_MAXmaxvalueoflong(+2,147,483,647)LONG_MINminvalueoflong(2,147,483,648)SCHAR_MAXmaxvalueofsignedchar(+127)SCHAR_MINminvalueofsignedchar(128)SHRT_MAXmaxvalueofshort(+32,767)SHRT_MINminvalueofshort(32,768)UCHAR_MAXmaxvalueofunsignedchar(255)UINT_MAXmaxvalueofunsignedint(65,535)ULONG_MAXmaxvalueofunsignedlong(4,294,967,295)USHRT_MAXmaxvalueofunsignedshort(65,536)FloatTypeLimitsloa;&#xt.h0;FLT_RADIXradixofexponentrep(2)FLT_ROUNDS\roatingpointroundingmodeFLT_DIGdecimaldigitsofprecision(6)FLT_EPSILONsmallestxso1:0+x6=1:0(105)FLT_MANT_DIGnumberofdigitsinmantissaFLT_MAXmaximum\roatingpointnumber(1037)FLT_MAX_EXPmaximumexponentFLT_MINminimum\roatingpointnumber(1037)FLT_MIN_EXPminimumexponentDBL_DIGdecimaldigitsofprecision(10)DBL_EPSILONsmallestxso1:0+x6=1:0(109)DBL_MANT_DIGnumberofdigitsinmantissaDBL_MAXmaxdouble\roatingpointnumber(1037)DBL_MAX_EXPmaximumexponentDBL_MINmindouble\roatingpointnumber(1037)DBL_MIN_EXPminimumexponentMay1999v1.3.Copyrightc\r1999JosephH.SilvermanPermissionisgrantedtomakeanddistributecopiesofthiscardpro-videdthecopyrightnoticeandthispermissionnoticearepreservedonallcopies.SendcommentsandcorrectionstoJ.H.Silverman,Math.Dept.,BrownUniv.,Providence,RI02912USA.hjhs@math.brown.edui456