asp.net c# pdf viewer : Break a pdf file application software utility html windows .net visual studio octave27-part494

Chapter14: InputandOutput
255
Iflenisomitted,fgetsreadsuntilthenextnewlinecharacter.
Iftherearenomorecharacterstoread,fgetsreturns 1.
Toreadalineanddiscardtheterminatingnewlineseefgetl.
See also: [fputs], page 253[fgetl],page 254[fscanf], page 261[fread], page 264,
[fopen],page252.
[Built-inFunction]
nlines = = fskipl
(
fid
)
[Built-inFunction]
nlines = = fskipl
(
fid
,
count
)
[Built-inFunction]
nlines = = fskipl
(
fid
,Inf)
Readandskipcountlinesfromthefilespecifiedbythefiledescriptorfid.
fskipldiscardscharactersuntilanend-of-lineisencounteredexactlycount-times,or
untiltheend-of-filemarkerisfound.
Ifcountis omitted,itdefaultsto1. . countmayalsobeInf,inwhichcaselinesare
skippeduntiltheendof the file. . Thisformis s suitable forcounting the number of
linesinafile.
Returnsthenumberoflinesskipped(end-of-linesequencesencountered).
Seealso: [fgetl],page254,[fgets],page254,[fscanf],page261,[fopen],page252.
14.2.4 FormattedOutput
Thissectiondescribeshowtocallprintfandrelatedfunctions.
Thefollowingfunctionsareavailableforformattedoutput.Theyaremodeledafterthe
Clanguagefunctionsofthesamename,buttheyinterprettheformattemplatedifferently
inordertoimprovetheperformanceofprintingvectorandmatrixvalues.
ImplementationNote:Forcompatibilitywithmatlab,escapesequencesinthetemplate
string(e.g.,"\n"=>newline)areexpandedevenwhenthetemplatestringisdefinedwith
singlequotes.
[Built-inFunction]
printf
(
template
,...)
Printoptionalarguments underthe controlofthe templatestring template e to o the
streamstdoutandreturnthenumberofcharactersprinted.
SeetheFormattedOutputsectionoftheGNUOctavemanualforacompletedescrip-
tionofthesyntaxofthetemplatestring.
ImplementationNote:Forcompatibilitywithmatlab,escapesequencesinthetem-
platestring(e.g.,"\n"=>newline)areexpandedevenwhenthetemplatestringis
definedwithsinglequotes.
Seealso: [fprintf],page255,[sprintf],page256,[scanf],page261.
[Built-inFunction]
fprintf
(
fid
,
template
,...)
[Built-inFunction]
fprintf
(
template
,...)
[Built-inFunction]
numbytes = = fprintf
(...)
This functionisequivalenttoprintf,except thattheoutput iswrittentothefile
descriptorfidinsteadofstdout.
Iffidisomitted,theoutputiswrittentostdoutmakingthefunctionexactlyequiv-
alenttoprintf.
Break a pdf file - Split, seperate PDF into multiple files in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Explain How to Split PDF Document in Visual C#.NET Application
pdf split and merge; cannot select text in pdf file
Break a pdf file - VB.NET PDF File Split Library: Split, seperate PDF into multiple files in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET PDF Document Splitter Control to Disassemble PDF Document
break apart pdf; split pdf by bookmark
256
GNUOctave
Theoptionaloutputreturnsthenumberofbyteswrittentothefile.
ImplementationNote:Forcompatibilitywithmatlab,escapesequencesinthetem-
platestring(e.g.,"\n"=>newline)areexpandedevenwhenthetemplatestringis
definedwithsinglequotes.
See also: [fputs],page253[fdisp],page244[fwrite], page 267,[fscanf],page261,
[printf],page255,[sprintf],page256,[fopen],page252.
[Built-inFunction]
sprintf
(
template
,...)
Thisislikeprintf,exceptthattheoutputisreturnedasastring.
Unlikethe Clibrary function,whichrequiresyoutoprovideasuitably sizedstring
asanargument,Octave’ssprintffunctionreturnsthestring,automaticallysizedto
holdalloftheitemsconverted.
ImplementationNote:Forcompatibilitywithmatlab,escapesequencesinthetem-
platestring(e.g.,"\n"=>newline)areexpandedevenwhenthetemplatestringis
definedwithsinglequotes.
Seealso: [printf],page255,[fprintf],page255,[sscanf],page262.
The printf f function n can be usedto print any number r of arguments. . The e template
stringargumentyousupplyinacallprovides informationnotonlyabout the number of
additionalarguments,butalsoabouttheirtypesandwhatstyleshouldbeusedforprinting
them.
Ordinary characters in the e template e string g are simply y written to o the e output stream
as-is,whileconversionspecifications introducedbya a ‘%’characterin the template cause
subsequentargumentstobeformattedandwrittentotheoutputstream.Forexample,
pct = 37;
filename = "foo.txt";
printf ("Processed %d%% % of ’%s’.\nPlease e be patient.\n",
pct, filename);
producesoutputlike
Processed 37% % of ’foo.txt’.
Please be e patient.
This example shows s the e use of the ‘%d’ conversion tospecify that a scalar r argument
shouldbeprintedindecimalnotation,the‘%s’conversionto specify printingofastring
argument,andthe‘%%’conversiontoprintaliteral‘%’character.
There are also conversions for r printing g an integer r argument as s anunsigned d value in
octal, decimal, or r hexadecimalradix x (‘%o’, ‘%u’, or ‘%x’, respectively); or r as a character
value(‘%c’).
Floating-point numbers canbe printed d innormal, fixed-point t notationusing the ‘%f’
conversionorinexponentialnotationusingthe‘%e’conversion. The‘%g’conversionuses
either‘%e’or‘%f’format,dependingonwhatismoreappropriateforthemagnitudeofthe
particularnumber.
You can control formatting more precisely y by writing g modifiers between n the ‘%’ and
thecharacter thatindicates whichconversiontoapply. . These e slightly alter the ordinary
behavior of f the conversion. . For r example, most conversion specifications permit you u to
C# PDF Convert: How to Convert Jpeg, Png, Bmp, & Gif Raster Images
Success"); break; case ConvertResult.FILE_TYPE_UNSUPPORT: Console.WriteLine("Fail: can not convert to PDF, file type unsupport"); break; case ConvertResult
cannot print pdf no pages selected; break up pdf into individual pages
C# Image Convert: How to Convert Word to Jpeg, Png, Bmp, and Gif
RasterEdge.XDoc.PDF.dll. case ConvertResult.NO_ERROR: Console.WriteLine("Success"); break; case ConvertResult Fail: can not convert to JPEG, file type unsupport
break pdf; how to split pdf file by pages
Chapter14: InputandOutput
257
specifyaminimumfieldwidthandaflagindicatingwhether youwant theresultleft-or
right-justifiedwithinthefield.
The specific c flags s and modifiers s that are permittedandtheir interpretation n vary y de-
pendingontheparticularconversion.They’realldescribedinmoredetailinthefollowing
sections.
14.2.5 OutputConversionforMatrices
Whengivenamatrixvalue,Octave’sformattedoutputfunctionscyclethroughtheformat
templateuntilallthevaluesinthematrixhavebeenprinted.Forexample:
printf ("%4.2f %10.2e %8.4g\n", , hilb b (3));
a
1.00
5.00e-01
0.3333
a 0.50
3.33e-01
0.25
a
0.33
2.50e-01
0.2
If more thanone value is tobe printed ina single call, the output t functions s do not
returntothebeginningoftheformattemplatewhenmovingonfromonevaluetothenext.
Thiscanleadtoconfusingoutputifthenumberofelementsinthematricesarenotexact
multiplesofthenumberofconversionsintheformattemplate. Forexample:
printf ("%4.2f %10.2e %8.4g\n", , [1, , 2], [3, 4]);
a
1.00
2.00e+00
3
a
4.00
Ifthisisnotwhatyouwant,useaseriesofcallsinsteadofjustone.
14.2.6 OutputConversionSyntax
Thissectionprovidesdetailsabouttheprecisesyntaxofconversionspecificationsthatcan
appearinaprintftemplatestring.
Characters in n the template string that are not t part t of f a conversionspecification are
printedas-istotheoutputstream.
Theconversionspecificationsinaprintftemplatestringhavethegeneralform:
% flags s width [ [ . . precision n ] ] type conversion
Forexample,intheconversionspecifier‘%-10.8ld’,the‘-’isaflag,‘10’specifiesthefield
width,theprecisionis‘8’,theletter‘l’isatypemodifier,and‘d’specifiestheconversion
style. (Thisparticulartypespecifiersaystoprintanumericargumentindecimalnotation,
withaminimumof8digitsleft-justifiedinafieldatleast10characterswide.)
Inmoredetail,outputconversionspecificationsconsistofaninitial‘%’characterfollowed
insequenceby:
 Zeroormoreflagcharactersthatmodifythenormalbehavioroftheconversionspeci-
fication.
 Anoptionaldecimalintegerspecifyingtheminimumfieldwidth. . Ifthenormalconver-
sionproducesfewercharactersthanthis,thefieldispaddedwithspacestothespecified
width. Thisisaminimum m value;ifthe e normalconversionproducesmorecharacters
thanthis,thefieldisnot truncated.Normally,theoutputisright-justifiedwithinthe
field.
C# PDF Page Insert Library: insert pages into PDF file in C#.net
Offer PDF page break inserting function. offers easy & mature APIs for developers to add & insert an (empty) page into an existing PDF document file.
break a pdf file into parts; c# print pdf to specific printer
VB.NET PDF Page Insert Library: insert pages into PDF file in vb.
Offer PDF page break inserting function. And this page will give comprehensive VB example codes to create a new page to any designed location of the PDF file.
break pdf into pages; pdf will no pages selected
258
GNUOctave
Youcanalsospecifyafieldwidthof‘*’. Thismeans s thatthenext argument inthe
argument list (beforetheactualvalue tobeprinted) isusedasthefieldwidth. . The
valueisroundedtothenearestinteger. Ifthevalueisnegative,thismeanstosetthe
‘-’flag(seebelow)andtousetheabsolutevalueasthefieldwidth.
 Anoptionalprecisiontospecify y the numberofdigits to be writtenfor the numeric
conversions. Iftheprecisionisspecified,itconsistsofaperiod(‘.’)followedoptionally
byadecimalinteger(whichdefaultstozeroifomitted).
Youcan also specify y a precisionof ‘*’. . This s means that the next argument in n the
argumentlist(beforetheactualvaluetobeprinted)isusedastheprecision. Thevalue
mustbeaninteger,andisignoredifitisnegative.
 Anoptionaltype e modifier character. . This s character is ignoredby Octave’s printf
function,butisrecognizedtoprovidecompatibilitywiththeClanguageprintf.
 Acharacterthatspecifiestheconversiontobeapplied.
The exactoptionsthat arepermittedandhow theyare interpretedvary betweenthe
differentconversionspecifiers. Seethedescriptionsoftheindividualconversionsforinfor-
mationabouttheparticularoptionsthattheyuse.
14.2.7 TableofOutputConversions
Hereisatablesummarizingwhatallthedifferentconversionsdo:
‘%d’,‘%i’ Printanintegerasasigneddecimalnumber. . SeeSection14.2.8[IntegerCon-
versions],page259,fordetails.‘%d’and‘%i’aresynonymousforoutput,butare
differentwhenusedwithscanfforinput(seeSection14.2.13[TableofInput
Conversions],page263).
‘%o’
Printanintegerasanunsignedoctalnumber.SeeSection14.2.8[IntegerCon-
versions],page259,fordetails.
‘%u’
Print anintegerasanunsigneddecimalnumber. . See Section14.2.8[Integer
Conversions],page259,fordetails.
‘%x’,‘%X’ Printanintegerasanunsignedhexadecimalnumber. . ‘%x’useslowercaseletters
and‘%X’usesuppercase.SeeSection14.2.8[IntegerConversions],page259,for
details.
‘%f’
Print a a floating-point number in normal (fixed-point) ) notation.
See
Section14.2.9[Floating-PointConversions],page260,fordetails.
‘%e’, ‘%E’
Print a a floating-point t number in n exponential l notation. . ‘%e’ ’ uses s lowercase
lettersand‘%E’usesuppercase.SeeSection14.2.9[Floating-PointConversions],
page260,fordetails.
‘%g’, ‘%G’
Print a a floating-point t number in either r normal l (fixed-point) ) or exponential
notation,whicheverismoreappropriateforitsmagnitude. ‘%g’useslowercase
lettersand‘%G’usesuppercase.SeeSection14.2.9[Floating-PointConversions],
page260,fordetails.
‘%c’
Print a single character. . See Section 14.2.10 [Other r Output Conversions],
page260.
‘%s’
Printastring. SeeSection14.2.10[OtherOutputConversions],page260.
C# TWAIN - Query & Set Device Abilities in C#
TWSX_NATIVE; // See if the device supports file transfer. device.TwainTransferMode = method; break; } if (method == TwainTransferMethod.TWSX_FILE) device
break password pdf; break pdf into multiple files
C# TWAIN - Install, Deploy and Distribute XImage.Twain Control
RasterEdge.XDoc.PDF.dll. See if the device supports file transfer device. TwainTransferMode = method; break; } if (method == TwainTransferMethod.TWSX_FILE)
break a pdf apart; break a pdf into separate pages
Chapter14: InputandOutput
259
‘%%’
Printaliteral‘%’character. SeeSection14.2.10[OtherOutputConversions],
page260.
Ifthesyntaxofaconversionspecificationisinvalid,unpredictablethingswillhappen,so
don’tdothis. Inparticular,matlaballowsabarepercentagesign‘%’withnosubsequent
conversioncharacter. Octave e willemitanerrorandstopifit sees suchcode. . Whenthe
stringvariabletobeprocessedcannotbeguaranteedtobefreeofpotentialformatcodesit
isbettertousethetwoargumentformofanyoftheprintffunctionsandsettheformat
stringto%s. Alternatively,forcodewhichisnotrequiredtobebackwards-compatiblewith
matlabtheOctavefunctionputsordispcanbeused.
printf (strvar);
# Unsafe if strvar r contains s format codes
printf ("%s", strvar); ; # # Safe
puts (strvar);
# Safe
Iftherearen’tenoughfunctionargumentsprovidedtosupplyvaluesforalltheconversion
specificationsinthetemplatestring,oriftheargumentsarenotofthecorrecttypes,the
resultsareunpredictable.Ifyousupplymoreargumentsthanconversionspecifications,the
extraargumentvaluesaresimplyignored;thisissometimesuseful.
14.2.8 IntegerConversions
This section n describes the options s for the ‘%d’, , ‘%i’, ‘%o’, ‘%u’, ‘%x’, and‘%X’ conversion
specifications.Theseconversionsprintintegersinvariousformats.
The‘%d’and‘%i’conversionspecificationsbothprintannumericargumentasasigned
decimalnumber;while‘%o’,‘%u’,and‘%x’printtheargumentasanunsignedoctal,decimal,
or hexadecimal l number r (respectively). . The e ‘%X’ conversionspecification is just like ‘%x’
exceptthatitusesthecharacters‘ABCDEF’asdigitsinsteadof‘abcdef’.
Thefollowingflagsaremeaningful:
‘-’
Left-justifytheresultinthefield(insteadofthenormalright-justification).
‘+’
Forthesigned‘%d’and‘%i’conversions,printaplussignifthevalueispositive.
‘’
Forthesigned‘%d’and‘%i’conversions,iftheresultdoesn’tstartwithaplus
orminussign,prefixitwithaspacecharacterinstead.Sincethe‘+’flagensures
thattheresultincludesasign,thisflagisignoredifyousupplybothofthem.
‘#’
Forthe‘%o’conversion,thisforcestheleadingdigittobe‘0’,asifbyincreasing
theprecision.For‘%x’or‘%X’,thisprefixesaleading‘0x’or‘0X’(respectively)to
theresult. Thisdoesn’tdoanythingusefulforthe‘%d’,‘%i’,or‘%u’conversions.
‘0’
Pad the e field with h zeros instead of f spaces. . The e zeros s are e placed d after any
indicationofsignorbase. Thisflagisignoredifthe‘-’flagisalsospecified,or
ifaprecisionisspecified.
Ifaprecisionissupplied,itspecifiestheminimumnumberofdigitstoappear;leading
zerosareproducedifnecessary.Ifyoudon’tspecifyaprecision,thenumberisprintedwith
asmanydigitsasitneeds.Ifyouconvertavalueofzerowithanexplicitprecisionofzero,
thennocharactersatallareproduced.
C# TWAIN - Acquire or Save Image to File
RasterEdge.XDoc.PDF.dll. is necessary in order to set the file format later Group4) device.Compression = TwainCompressionMode.Group3; break; } } acq.FileTranfer
break pdf into smaller files; break a pdf into smaller files
C# TWAIN - Specify Size and Location to Scan
How to Save Acquired Image to File in C#.NET with in frames) { if (frame == TwainStaticFrameSizeType.LetterUS) { this.device.FrameSize = frame; break; } } }.
break password on pdf; pdf split pages
260
GNUOctave
14.2.9 Floating-PointConversions
This sectiondiscusses s the e conversion specifications for floating-point t numbers: : the e ‘%f’,
‘%e’,‘%E’,‘%g’,and‘%G’conversions.
The‘%f’conversionprintsitsargumentinfixed-pointnotation,producingoutputofthe
form[-]ddd.ddd,wherethenumberofdigitsfollowingthedecimalpointiscontrolledby
theprecisionyouspecify.
The ‘%e’ conversionprints itsargument inexponentialnotation,producing output of
the form [-]d.ddde[+|-]dd. . Again, , the e number r of digits following the decimal l point t is
controlledby the precision. . Theexponent t always contains atleast two digits. . The e ‘%E’
conversionissimilarbuttheexponentismarkedwiththeletter‘E’insteadof‘e’.
The‘%g’and‘%G’conversionsprinttheargumentinthestyleof‘%e’or‘%E’(respectively)
iftheexponentwouldbeless than-4orgreaterthanorequaltotheprecision;otherwise
theyusethe‘%f’style.Trailingzerosareremovedfromthefractionalportionoftheresult
andadecimal-pointcharacterappearsonlyifitisfollowedbyadigit.
Thefollowingflagscanbeusedtomodifythebehavior:
‘-’
Left-justifytheresultinthefield. Normallytheresultisright-justified.
‘+’
Alwaysincludeaplusorminussignintheresult.
‘’
If the result doesn’t t start with aplus s or r minus s sign, , prefix x it t with aspace
instead. Since e the ‘+’flagensures thattheresult includes asign,thisflagis
ignoredifyousupplybothofthem.
‘#’
Specifiesthattheresultshouldalwaysincludeadecimalpoint,evenifnodigits
followit. Forthe‘%g’and‘%G’conversions,thisalsoforcestrailingzerosafter
thedecimalpointtobeleftinplacewheretheywouldotherwiseberemoved.
‘0’
Padthefieldwithzerosinsteadofspaces;thezerosareplacedafteranysign.
Thisflagisignoredifthe‘-’flagisalsospecified.
Theprecisionspecifieshowmanydigitsfollowthedecimal-pointcharacterforthe‘%f’,
‘%e’,and‘%E’conversions.Fortheseconversions,thedefaultprecisionis6. Iftheprecision
is explicitly0,thissuppresses thedecimalpoint characterentirely. . For r the‘%g’and‘%G’
conversions,theprecisionspecifieshowmanysignificantdigits toprint. . Significant t digits
arethefirstdigitbeforethedecimalpoint,andallthedigitsafterit. Iftheprecisionis0
or not specifiedfor‘%g’or‘%G’,itis treatedlike avalueof1. . If f the valuebeingprinted
cannotbeexpressedpreciselyinthespecifiednumberofdigits,thevalueisroundedtothe
nearestnumberthatfits.
14.2.10 OtherOutputConversions
Thissectiondescribesmiscellaneousconversionsforprintf.
The ‘%c’conversionprints asinglecharacter. . The e ‘-’flagcanbeusedtospecifyleft-
justificationinthefield,butnoother flags aredefined,andnoprecisionortypemodifier
canbegiven.Forexample:
printf ("%c%c%c%c%c", "h", , "e", "l", , "l", "o");
prints‘hello’.
Chapter14: InputandOutput
261
The ‘%s’conversionprintsastring. . Thecorrespondingargument t mustbeastring. . A
precisioncanbespecifiedtoindicatethemaximumnumberofcharacterstowrite;otherwise
charactersinthestringuptobutnotincludingtheterminatingnullcharacterarewritten
totheoutputstream. The‘-’flagcanbeusedtospecifyleft-justificationinthefield,but
nootherflagsortypemodifiersaredefinedforthisconversion. Forexample:
printf ("%3s%-6s", "no", "where");
prints‘nowhere’(notetheleadingandtrailingspaces).
14.2.11 FormattedInput
Octaveprovidesthescanf,fscanf,andsscanffunctionstoreadformattedinput. There
aretwoformsofeachofthesefunctions. Onecanbeusedtoextractvectorsofdatafrom
afile,andtheotherismore‘C-like’.
[Built-inFunction]
[val, count, errmsg] = = fscanf
(
fid
,
template
,
size
)
[Built-inFunction]
[v1, v2, , ..., , count, errmsg] = = fscanf
(
fid
,
template
,
"
C
"
)
Inthe first form, read from fid according totemplate, returningthe result in the
matrixval.
Theoptionalargumentsizespecifiestheamountofdatatoreadandmaybeoneof
Inf
Readasmuchaspossible,returningacolumnvector.
nr
Readuptonr elements,returningacolumnvector.
[nr,Inf] Readasmuchaspossible,returningamatrixwithnrrows.Ifthenumber
ofelementsreadisnotanexactmultipleofnr,thelastcolumnispadded
withzeros.
[nr,nc]
Readuptonr*nc elements,returninga matrix with h nr rows. . If f the
numberofelementsreadisnotanexactmultipleofnr,thelastcolumn
ispaddedwithzeros.
Ifsizeisomitted,avalueofInfisassumed.
Astringisreturnediftemplatespecifiesonlycharacterconversions.
Thenumberofitemssuccessfullyreadisreturnedincount.
Ifanerroroccurs,errmsgcontainsasystem-dependenterrormessage.
Inthesecondform,readfromfidaccordingtotemplate,witheachconversionspecifier
intemplatecorrespondingtoasinglescalarreturnvalue.Thisformismore“C-like”,
and also compatible e with h previous versions of f Octave. . The e number of f successful
conversionsisreturnedincount
SeetheFormattedInputsectionoftheGNUOctavemanualforacompletedescription
ofthesyntaxofthetemplatestring.
See also: [fgets], page 254[fgetl], page 254[fread], page 264[scanf], page 261,
[sscanf],page262,[fopen],page252.
[Built-inFunction]
[val, count, errmsg] = = scanf
(
template
,
size
)
[Built-inFunction]
[v1, v2, , ..., , count, errmsg]] = scanf
(
template
,
"
C
"
)
Thisisequivalenttocallingfscanfwithfid=stdin.
262
GNUOctave
Itiscurrentlynotusefultocallscanfininteractiveprograms.
Seealso: [fscanf],page261,[sscanf],page262,[printf],page255.
[Built-inFunction]
[val, count, errmsg, pos] = = sscanf
(
string
,
template
,
size
)
[Built-inFunction]
[v1, v2, , ..., , count, errmsg] = = sscanf
(
string
,
template
,
"
C
"
)
Thisislikefscanf,exceptthatthecharactersaretakenfromthestringstringinstead
offromastream.
Reachingtheendofthestringistreatedasanend-of-filecondition. Inadditionto
thevaluesreturnedbyfscanf,theindexofthenextcharactertobereadisreturned
inpos.
Seealso: [fscanf],page261,[scanf],page261,[sprintf],page256.
Callstoscanfaresuperficiallysimilartocallstoprintfinthatarbitraryargumentsare
readunderthecontrolofatemplatestring.Whilethesyntaxoftheconversionspecifications
inthe template is very similar tothat for printf, the interpretationofthe template is
orientedmoretowardsfree-formatinputandsimplepatternmatching,rather thanfixed-
fieldformatting. For r example, , most t scanf conversions skipover any amount t of f “white
space” (including spaces, tabs, andnewlines) in the input t file, andthere e is s no o concept
of precision n for the e numeric c input conversions s as there e is s for the e corresponding g output
conversions. Ordinarily,non-whitespacecharactersinthetemplateareexpectedtomatch
charactersintheinputstreamexactly.
When a matching failure e occurs, , scanf f returns immediately, , leaving the first t non-
matchingcharacterasthenextcharactertobereadfromthestream,andscanfreturnsall
theitemsthatweresuccessfullyconverted.
Theformattedinputfunctionsarenotusedasfrequentlyastheformattedoutputfunc-
tions. Partly,thisisbecause e ittakessomecaretousethemproperly. . Anotherreasonis
thatitisdifficulttorecoverfromamatchingerror.
14.2.12 InputConversionSyntax
Ascanftemplatestringisastringthatcontainsordinarymultibytecharactersinterspersed
withconversionspecificationsthatstartwith‘%’.
Anywhitespacecharacterinthetemplatecausesanynumberofwhitespacecharacters
intheinputstreamtobereadanddiscarded. Thewhitespacecharactersthatarematched
neednotbeexactlythesamewhitespacecharactersthatappearinthetemplatestring.For
example,write‘,’inthetemplatetorecognizeacommawithoptionalwhitespacebefore
andafter.
Other characters inthe templatestringthat are not part of conversion n specifications
must match h characters s in n the input stream exactly; ; if f this is s not the case, , a a matching
failureoccurs.
Theconversionspecificationsinascanftemplatestringhavethegeneralform:
% flags s width type conversion
Inmoredetail,aninputconversionspecificationconsistsofaninitial‘%’characterfol-
lowedinsequenceby:
Chapter14: InputandOutput
263
 Anoptionalflagcharacter‘*’,whichsaystoignorethetextreadforthisspecification.
Whenscanffindsaconversionspecificationthatusesthisflag,itreadsinputasdirected
bytherestoftheconversionspecification,butitdiscardsthisinput,doesnotreturn
anyvalue,anddoesnotincrementthecountofsuccessfulassignments.
 Anoptionaldecimalintegerthatspecifiesthemaximumfieldwidth. . Readingofchar-
acters fromthe inputstreamstops either whenthis maximum m isreachedorwhena
non-matching characteris found,whichever happens first. . Mostconversions s discard
initialwhitespacecharacters,andthesediscardedcharactersdon’tcounttowardsthe
maximumfieldwidth. Conversionsthatdonotdiscardinitialwhitespaceareexplicitly
documented.
 An n optional type modifier r character. . This s character is s ignored d by Octave’s scanf
function,butisrecognizedtoprovidecompatibilitywiththeClanguagescanf.
 Acharacterthatspecifiestheconversiontobeapplied.
The exactoptionsthat arepermittedandhow theyare interpretedvary betweenthe
differentconversionspecifiers. Seethedescriptionsoftheindividualconversionsforinfor-
mationabouttheparticularoptionsthattheyallow.
14.2.13 TableofInputConversions
Hereisatablethatsummarizesthevariousconversionspecifications:
‘%d’
Matchesanoptionally signedintegerwrittenindecimal. . See Section14.2.14
[NumericInputConversions],page264.
‘%i’
MatchesanoptionallysignedintegerinanyoftheformatsthattheClanguage
definesforspecifyinganintegerconstant. SeeSection14.2.14[NumericInput
Conversions],page264.
‘%o’
Matchesanunsignedinteger writteninoctalradix. . SeeSection14.2.14[Nu-
mericInputConversions],page264.
‘%u’
Matches an n unsigned integer written in decimal radix. . See Section 14.2.14
[NumericInputConversions],page264.
‘%x’,‘%X’
Matchesanunsignedintegerwritteninhexadecimalradix. SeeSection14.2.14
[NumericInputConversions],page264.
‘%e’,‘%f’,‘%g’,‘%E’,‘%G’
Matchesanoptionallysignedfloating-pointnumber. SeeSection14.2.14[Nu-
mericInputConversions],page264.
‘%s’
Matchesastringcontainingonlynon-whitespacecharacters.SeeSection14.2.15
[StringInputConversions],page264.
‘%c’
Matchesastringofoneormorecharacters;thenumberofcharactersreadiscon-
trolledbythemaximumfieldwidthgivenfortheconversion.SeeSection14.2.15
[StringInputConversions],page264.
‘%%’
This matches s a literal l ‘%’ character r in n the input stream. . No o corresponding
argumentisused.
264
GNUOctave
Ifthesyntaxofaconversionspecificationisinvalid,thebehaviorisundefined. Ifthere
aren’tenoughfunctionargumentsprovidedtosupplyaddressesforalltheconversionspec-
ificationsinthetemplatestringsthatperformassignments,oriftheargumentsarenotof
thecorrecttypes,thebehaviorisalsoundefined. Ontheotherhand,extraargumentsare
simplyignored.
14.2.14 NumericInputConversions
Thissectiondescribesthescanfconversionsforreadingnumericvalues.
The‘%d’conversionmatchesanoptionallysignedintegerindecimalradix.
The‘%i’conversionmatchesanoptionallysignedintegerinanyoftheformatsthatthe
Clanguagedefinesforspecifyinganintegerconstant.
For example,any ofthestrings‘10’,‘0xa’,or‘012’couldbereadinasintegersunder
the‘%i’conversion. Eachofthesespecifiesanumberwithdecimalvalue10.
The‘%o’,‘%u’,and‘%x’conversionsmatchunsignedintegersinoctal,decimal,andhex-
adecimalradices,respectively.
The‘%X’conversionisidenticaltothe‘%x’conversion.Theybothpermiteitheruppercase
orlowercaseletterstobeusedasdigits.
UnliketheClanguagescanf,Octaveignoresthe‘h’,‘l’,and‘L’modifiers.
14.2.15 StringInputConversions
Thissectiondescribesthescanfinputconversionsforreadingstringandcharactervalues:
‘%s’and‘%c’.
The‘%c’conversionisthesimplest:itmatchesafixednumberofcharacters,always.The
maximumfieldwithsayshowmanycharacterstoread;ifyoudon’tspecifythemaximum,
thedefaultis1. Thisconversiondoesnotskipoverinitialwhitespacecharacters. Itreads
preciselythenextncharacters,andfailsifitcannotgetthatmany.
The ‘%s’conversionmatches a stringof non-whitespace characters. . It t skips s and d dis-
cards initialwhitespace,butstopswhenitencountersmorewhitespaceafterhavingread
something.
Forexample,readingtheinput:
hello, world
withthe conversion ‘%10c’ produces "hello,wo",butreadingthe sameinput with the
conversion‘%10s’produces"hello,".
14.2.16 BinaryI/O
Octavecanreadandwritebinarydatausingthefunctions freadandfwrite,whichare
patternedafterthestandardCfunctionswiththesamenames. Theyareabletoautomat-
icallyswapthebyteorderofintegerdataandconvertamongthesupportedfloatingpoint
formatsasthedataareread.
[Built-inFunction]
val = = fread
(
fid
)
[Built-inFunction]
val = = fread
(
fid
,
size
)
[Built-inFunction]
val = = fread
(
fid
,
size
,
precision
)
[Built-inFunction]
val = = fread
(
fid
,
size
,
precision
,
skip
)
Documents you may be interested
Documents you may be interested