12 Pages

DA05A_Lecture_adv

Course: H 192, Fall 2009
School: National Taiwan University
Rating:
 
 
 
 
 

Word Count: 619

Document Preview

H192 Engineering - Computer Programming Daily Assignment A05 Advanced Tips and Hints Detecting Errors in the Input Sream & Flushing Characters Out of the Stream Winter Quarter The Ohio State University Gateway Engineering Education Coalition P. 1 Engineering H192 - Computer Programming scanf If successful, scanf returns the number of items successfully read which will be between 0 and the number...

Register Now

Unformatted Document Excerpt

Coursehero >> China >> National Taiwan University >> H 192

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
H192 Engineering - Computer Programming Daily Assignment A05 Advanced Tips and Hints Detecting Errors in the Input Sream & Flushing Characters Out of the Stream Winter Quarter The Ohio State University Gateway Engineering Education Coalition P. 1 Engineering H192 - Computer Programming scanf If successful, scanf returns the number of items successfully read which will be between 0 and the number variables list in the call to scanf If the input stream is exhausted (at end-of-file), scanf returns an indication of end-of-file, or "EOF" (-1) returnValue = scanf ("%d%d",&a,&b); -1 EOF 0 1 Conversion error Got a, error while while scanning for a looking for b The Ohio State University Gateway Engineering Education Coalition 2 Found both a and b P. 2 Winter Quarter Engineering H192 - Computer Programming scanf Example #include <stdio.h> int main( ) { int returnValue, a, b, x; for (x = 0 ; x < 3 ; x++) { //Prompt and Get User Input printf ("Enter String: "); returnValue = scanf ("%d%d", &a, &b); //Print Variable Values printf ("\nreturnValue = %d\n", returnValue); printf ("a = %d\n",a); printf ("b = %d\n",b); } } Winter Quarter The Ohio State University Gateway Engineering Education Coalition P. 3 Engineering H192 - Computer Programming Tracing the scanf Example Enter String: Winter Quarter The Ohio State University Gateway Engineering Education Coalition P. 4 Engineering H192 - Computer Programming Tracing the scanf Example Enter String: 4 5<CR> returnValue = a = b = Winter Quarter The Ohio State University Gateway Engineering Education Coalition P. 5 Engineering H192 - Computer Programming Tracing the scanf Example Enter String: 4 5<CR> returnValue = 2 a = 4 b = 5 Text in Buffer Before Prompt "" Text in Buffer Before scan "4 5\n" After scanf ("%d%d", &a, &b); "\n" Winter Quarter The Ohio State University Gateway Engineering Education Coalition P. 6 Engineering H192 - Computer Programming Tracing the scanf Example Enter String: 4 5<CR> returnValue = 2 a = 4 b = 5 Enter String: 6 fish<CR> returnValue = a = b = Winter Quarter The Ohio State University Engineering Gateway Education Coalition P. 7 Engineering H192 - Computer Programming Tracing the scanf Example Enter String: 4 5<CR> returnValue = 2 a = 4 b = 5 Enter String: 6 fish<CR> returnValue = 1 a = 6 b = 5 Text in Buffer Before 2nd Prompt "\n" Text in Buffer Before 2nd scan "\n6 fish\n" After 2nd scanf ("%d%d", &a, &b); "fish\n" b remains unchanged Winter Quarter The Ohio State University Gateway Engineering Education Coalition P. 8 Engineering H192 - Computer Programming Tracing the scanf Example Enter String: 4 5<CR> returnValue = 2 a = 4 b = 5 Enter String: 6 fish<CR> returnValue = 1 a = 6 b = 5 Enter String: returnValue = 0 a = 6 b = Quarter 5 Winter Text in Buffer Before 2nd Prompt "fish\n" Text in Buffer Before 2nd scan "fish\n" After 2nd scanf ("%d%d", &a , &b); "fish\n" Doesn't Wait for Input!! a & b are unchanged! The Ohio State University Gateway Engineering Education Coalition P. 9 Engineering H192 - Computer Programming Getting the "fish\n" Out of the Stream Remove characters one by one while (scanf ("%c", &c) != 0); Once `h' is removed, it prompts for user input while ( getchar( ) != `\n'); Once `h' is removed, it finds `\n' and stops Winter Quarter The Oh...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

UCLA - HIST - 597
HAWAIIANS ON TOUR111Hawaiians on Tour: Hula Circuits through the American EmpireADRIA L. IMADA University of California, Los AngelesA GROUP OF INFLUENTIAL HAWAIIANSA PRINCESS, A FAMED HULA DANCER, AND A composergathered at a Honolulu home in 1919 to j
UCLA - HIST - 597
Back to Hong Kong: Return migration or transnational sojourn?David Ley (University of British Columbia) and Audrey Kobayashi (Queen's University) August 2004Abstract. This paper re-considers the act of return migration in a period of growing transnation
UCLA - HIST - 597
EARLY AMERICAN NATIONS49Early American Nations as Imagined CommunitiesED WHITE Louisiana State UniversityBY THE END OF THE 1980S CULTURAL CRITICS SPOKE REGULARLY AND CONFIDENTLY of an analytical &quot;Holy Trinity&quot;: Race, Class, and Gender, three categorie
Western Washington - IT - 444
Inspiration Quick Start Tutorial1Inspiration Quick Start TutorialThis tutorial is a great starting point for learning how to use Inspiration. Please plan on about 45 minutes from start to finish. If youre new to Inspiration and like to learn while work
Allan Hancock College - OFM - 22009
test
SUNY Buffalo - CSE - 305
WG14/N1124Committee Draft May 6, 2005ISO/IEC 9899:TC2ContentsForeword Introduction 1. Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Drexel - ENGR - 663
Programming TechniquesR. Morris EditorOn the Criteria To Be Used in Decomposing Systems into ModulesD.L. Parnas Carnegie-Mellon UniversityThis paper discusses modularization as a mechanism for improving the flexibility and comprehensibility of a syste
Denison - CS - 281
MIPS32 Instruction Set Quick ReferenceRD RS, RT RA PC ACC LO, HI : R2DOTTEDLOGICAL AND BIT-FIELD OPERATIONS AND ANDI RD, RS, RT RD, RS, CONST16 RD, RS, P, S RD, RS, P, S RD = RS &amp; RT RD = RS &amp; CONST16 RS = R SP+S-1:P JUMPS AND BRANCHES (NOTE: ONE DEL
Sanford-Brown Institute - CSCI - 0310
Maze Help SessionOverview Structs in assembly Memory Management Breadth-first search Implementation Specifics What We Give You, What You Give Us Q&amp;AStructs In AssemblyTake a block of memory and use words/bytes in that block for different data; define
Sanford-Brown Institute - EN - 174
QUICK REFERENCE CARDNavigation TabsBrowser ControlsNavigator WindowBrowser WindowGraphics WindowPrompt AreaDashboard Example: Component PlacementInterface/Manual PlacementPlacement TabCommon Dashboard ControlsFeature Hole Round Depth MaterialS
SUNY Buffalo - EE - 449
Instruction on padframeThe padframe is a 40-pins padframe for the AMI ABN 1.6um process from MOSIS located at http:/www.mosis.org/cell-libraries/scn16-pads/. You should download the CIF file from the link as below and save it to your Cadence working dire
Emory - CS - 153000
Files and DataWe're starting to write real programs now, and real programs need to be able to read and write files to and from your hard drive. At the moment, all we can do is ask the user for input using &lt;STDIN&gt; and print data on the screen using print.
Emory - CS - 153000
Loops and DecisionsMost of the programs so far have been very simply structured they've done one statement after another in turn. If we were to represent statements as boxes, our programs would look like this:StatementStatementStatementThis sort of d
Wyoming - GEOL - 1100
2009 GEOLOGIC TIME SCALECENOZOICCHRON. ANOM. ANOM. HIST. HIST.MESOZOICCHRON.PALEOZOICPICKS (Ma)65.5 70.6PRECAMBRIANPICKS (Ma)251 254 260 266 268 271 276 284 297 299.0 304 306 312 318 326 1500 750AGE (Ma)MAGNETIC POLARITYPERIODQUATERNARYEPOC
East Los Angeles College - MEETING - 060905
TSF to ZPD transmission testEfficiency 1 0.75 0.5 0.25 0ZPD-00x xx xx X14 10X1520X030X140X250 TSF Sector/Layerx xx x 60 X3Efficiency1 0.75 0.5 0.25 0ZPD-10x xx xx 10 X0X120X230X340X450 TSF Sector/Layerx xx x 60 X5Efficiency1 0
East Los Angeles College - MEETING - 061128
Processing RELEASE/TrgTools/TriggerStatistics.C(&quot;30k-0050577.root&quot;,&quot;ps&quot;). Total number events: 30000 Overall L1 efficiency: &gt; 99.990% (95% C.L.) Pure DCT: 50.847% +- 0.289% Pure EMT: 38.167% +- 0.280% Mixed: 47.357% +- 0.288% Failed L1: &lt; 0.010% (9
East Los Angeles College - MEETING - 060905
TSF to ZPD transmission testEfficiency 1 0.75 0.5 0.25 0ZPD-00x xx xx X14 10X1520X030X140X250 TSF Sector/Layerx xx x 60 X3Efficiency1 0.75 0.5 0.25 0ZPD-10x xx xx 10 X0X120X230X340X450 TSF Sector/Layerx xx x 60 X5Efficiency1 0
East Los Angeles College - MEETING - 060905
TSF to ZPD transmission testEfficiency 1 0.75 0.5 0.25 0ZPD-00x xx xx X14 10X1520X030X140X250 TSF Sector/Layerx xx x 60 X3Efficiency1 0.75 0.5 0.25 0ZPD-10x xx xx 10 X0X120X230X340X450 TSF Sector/Layerx xx x 60 X5Efficiency1 0
East Los Angeles College - MEETING - 060815
Lumi Ratio Bhabha / Lumi Mupair15 14.8 14.6 14.4 14.2Lumi Ratio Mupair(BC) / Lumi Mupair 1.2 1.19 1.18 1.17 1.16 1.1514 1.14 13.8 13.6 13.4 13.2 0.5 1.13 1.12 1.11 1 1.5 2 2.5 3 3.5 250 pb-1/bin 1.1 0.5 1 1.5 2 2.5 3 3.5 250 pb-1/binLumi Ratio Gamma /
East Los Angeles College - MEETING - 060829
TSF to ZPD transmission testEfficiency 1 0.75 0.5 0.25 0ZPD-00x xx xx X14 10X1520X030X140X250 TSF Sector/Layerx xx x 60 X3Efficiency1 0.75 0.5 0.25 0ZPD-10x xx xx 10 X0X120X230X340X450 TSF Sector/Layerx xx x 60 X5Efficiency1 0
East Los Angeles College - MEETING - 060718
Lumi Ratio Gamma / Mupair(BC)1.581.5751.571.5651.561.55512345678 250 pb-1/bin
East Los Angeles College - MEETING - 060530
Luminosity Ratio and its Error from Run 64830May 30, 2006W ee-[mm]-[gg]-BCmha-BC[mm]10 140 120 100 80 60 40 20 0 03h1d2 Entries Mean RMS Underflow Overflow Integral 32321 1.031 1.118 0 01.775e+050.511.522.533.544.55LuminosityRatio = R =L
East Los Angeles College - MEETING - 060117
1. should we prescale the ZPD data &amp;/or input data (currently both prescales = 1)2. we currently do not have a xyplex port for the dcz slot 0 rom (odf-dct1-0 is tsf-y). this was supposed to be tempory. so we should think about fixing it.3. current tsf l
East Los Angeles College - MEETING - 061121
E-map raw trigger times (CLK8) (id 4)2500h9Entries 14106 Mean 38.78 RMS 2.15 Underflow 0 Overflow 0 Integral 1.411e+0420001500100050000102030405060E-map raw trigger times (CLK8) (id 4)2500h9Entries Mean RMS Underflow Overflow Integral 1
East Los Angeles College - MEETING - 060228
Residual z0bestZ0Res = aZpdTrackDigi-&gt;z0() extr.z0() ; Extr =&gt; ExtrapolationBeginning Run 5bLatest Run 5bBeginning Run 5bLatest Run 5b
University of Hawaii - Hilo - MARE - 390
REPORTSKiller Whale Predation on Sea Otters Linking Oceanic and Nearshore EcosystemsJ. A. Estes,* M. T. Tinker, T. M. Williams, D. F. DoakAfter nearly a century of recovery from overhunting, sea otter populations are in abrupt decline over large areas
Wayne State University - GST - 2710
Kenai Fjords National ParkUser: Date: Purpose: To display attendance information for the parkKenai Fjords National Park UsageMonth Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Exit Glacier Visitor Center 186 202 129 144 404 603 848 1,195 11,655 3,19
Wayne State University - GST - 2710
Vega TelescopesAuthor: Date: Purpose: United States sales figures for three Vega telescopesVega TelescopesMonthly US Sales For the Year Ending December 31, 2006Vega Telescope Sales (United States)MonthJanuary February March April May June July Augus
Wayne State University - GST - 2710
Vega TelescopesAuthor: Date: Purpose: The annual sales report for four of the top-selling Vega modelsVega TelescopesAnnual Sales Figures For the Year Ending December 31, 2006ModelBrightStar 6 BrightStar 8 NightVision 12 NightVision 16 TotalUnited St
Wayne State University - GST - 2710
NewGeneration Monitors Author: Date: Purpose:To report regional sales figures on three NewGeneration monitors.NewGeneration Monitors Regional Sales Report 1/1/2006 - 12/31/2006 Sales by Region Region VX100 VX300 Flatscreen Total Northeast 1723 2248 520
Wayne State University - GST - 2710
Wizard Works Author Date PurposeTo enter orders for Wizard WorksWizard Works Orders for March, 2007Shipping Costs Standard Discount for orders &gt; $200$8.95 Express 5% Price $29.95 $19.95 $19.95 Subtotal Shipping Discount TOTAL Qty 2 1 3Customer Wilson
Wayne State University - GST - 2710
NewGeneration Monitors Author: Date: Purpose:To report and analyze annual sales figures from three NewGeneration monitorsNewGeneration Monitors Sales Data 1/1/2006 - 12/31/2006 Monthly Sales Data Month VX100 VX300 FlatScreen January 1410 1860 February 1
Wayne State University - GST - 2710
Sonic Sounds Author: Date: Purpose:To record payroll information for the employees of Sonic SoundsPayroll Information Today's Date Health Plans Total Salaries Total 401(k) Contributions Total Health Insurance5/1/2006 Premier Standard $6,500 $5,500 401(
Wayne State University - GST - 2710
Wizard Works Author Date PurposeTo create a sales report for Wizard Works products.Wizard Works Sales Summary Regions Region 1 Region 2 Region 3 Region 4 Total Average Minimum Maximum Fountains Units Sold Percent Firecrackers Units Sold Percent Rockets
Wayne State University - GST - 2710
Giles Family Budget Created By: Date Created: Purpose: To analyze financial data from the Giles family budgetGiles Family Budget Year 2006 Figures Monthly Figures Income Jan Ken's Salary Ava's Salary Total Taxes Mortgage Car Payments Health Insurance Oth
Wayne State University - GST - 2710
Year Sales2006 Net Sales 12,510 Cost of Sales 4,140 Gross Margin2005 10,981 3,8102004 9,004 3,011 Shares Net income per share 3,581 3001Expenses Operting Income Other Income Pre-tax Income Income Tazes Net Income*(milllions except per-share amounts)
Wayne State University - GST - 2710
Lifestyles Home Care, Inc.284 Central Street Woburn, MA 01801 (781) 555-3038 November 4, 2010Dear Partner in Health Care: Lifestyles Home Care has consistently provided quality home care services to elderly and disabled clients when they are discharged
Bowling Green - FI - 8000
Futures and Forward Contracts 1. Follow the price of an S&amp;P 500 Futures contract (traded on the CME) for 5 days. Use the contract that calls for delivery in a month or so. Assume that the initial margin is $20,000 and the variation margin is $15,000 per c
NJIT - CIS - 332
Module 19: SecurityI The Security Problem I Authentication I Program Threats I System Threats I Securing Systems I Intrusion Detection I Encryption I Windows NTOperating System Concepts19.1Silberschatz, Galvin and Gagne 2002The Security ProblemI Sec
NJIT - CIS - 332
Chapter 17 Distributed CoordinationI Event Ordering I Mutual Exclusion I Atomicity I Concurrency Control I Deadlock Handling I Election Algorithms I Reaching AgreementOperating System Concepts17.1Silberschatz, Galvin and Gagne 2002Event OrderingI Ha
NJIT - CIS - 332
Chapter 10: Virtual MemoryI Background I Demand Paging I Process Creation I Page Replacement I Allocation of Frames I Thrashing I Operating System ExamplesOperating System Concepts10.1Silberschatz, Galvin and Gagne 2002BackgroundI Virtual memory sep
NJIT - CIS - 332
Module 15: Network StructuresI Background I Topology I Network Types I Communication I Communication Protocol I Robustness I Design StrategiesOperating System Concepts15.1Silberschatz, Galvin and Gagne 2002A Distributed SystemOperating System Concep
NJIT - CIS - 332
Chapter 8: DeadlocksI System Model I Deadlock Characterization I Methods for Handling Deadlocks I Deadlock Prevention I Deadlock Avoidance I Deadlock Detection I Recovery from Deadlock I Combined Approach to Deadlock HandlingOperating System Concepts8.
NJIT - CIS - 332
Chapter 7: Process SynchronizationI Background I The Critical-Section Problem I Synchronization Hardware I Semaphores I Classical Problems of Synchronization I Critical Regions I Monitors I Synchronization in Solaris 2 &amp; Windows 2000Operating System Con
NJIT - CIS - 332
Chapter 6: CPU SchedulingI Basic Concepts I Scheduling Criteria I Scheduling Algorithms I Multiple-Processor Scheduling I Real-Time Scheduling I Algorithm EvaluationOperating System Concepts6.1Silberschatz, Galvin and Gagne 2002Basic ConceptsI Maxim
NJIT - CIS - 332
Chapter 4: ProcessesI Process Concept I Process Scheduling I Operations on Processes I Cooperating Processes I Interprocess Communication I Communication in Client-Server SystemsOperating System Concepts4.1Silberschatz, Galvin and Gagne 2002Process C
NJIT - CIS - 332
Chapter 3: Operating-System StructuresI System Components I Operating System Services I System Calls I System Programs I System Structure I Virtual Machines I System Design and Implementation I System GenerationOperating System Concepts3.1Silberschatz
NJIT - CIS - 332
Chapter 2: Computer-System StructuresI Computer System Operation I I/O Structure I Storage Structure I Storage Hierarchy I Hardware Protection I General System ArchitectureOperating System Concepts2.1Silberschatz, Galvin and Gagne 2002Computer-System
Maryland - EDMS - 722
SIMPLIS Guide 2009 Mueller &amp; HancockS IMPLIS S OFTWARE G UIDEGoSIMPLIS Software Guide EDMS 722, Spring 2009SIMPLIS GuideThis introductory guide to the SIMPLIS command language of LISREL is not intended to replace the detailed information available i
Old Dominion - COMP - 3361
Lectures on distributed systemsRemote Procedure CallsPaul KrzyzanowskiIntroduction, or what's wrong with sockets?are a fundamental part of client-server networking. They provide a relatively easy mechanism for a program to establish a connection to an
Old Dominion - COMP - 3361
WEB SEARCH FOR A PLANET: THE GOOGLE CLUSTER ARCHITECTUREAMENABLE TO EXTENSIVE PARALLELIZATION, GOOGLES WEB SEARCHAPPLICATION LETS DIFFERENT QUERIES RUN ON DIFFERENT PROCESSORS AND, BY PARTITIONING THE OVERALL INDEX, ALSO LETS A SINGLE QUERY USE MULTIPLE
Old Dominion - COMP - 3361
Chapter 2: Operating-System StructuresSilberschatz, Galvin and Gagne 2009Chapter 2: Operating-System Structuress Operating System Services s User Operating System Interface s System Calls s Types of System Calls s System Programs s Operating System Des
Old Dominion - COMP - 3361
Chapter 1: IntroductionSilberschatz, Galvin and Gagne 2009Chapter 1: Introductions What Operating Systems Do s Computer-System Organization s Computer-System Architecture s Operating-System Structure s Operating-System Operations s Process Management s
University of Florida - ARC - 3181
UNL - CHEM - 869
Henry's Law and the Bends Scuba divers must be very conscious of Caisson's disease, commonly called 'The Bends'. The Bends is a nitrogen solubility problem. Since the air we breathe is 78% nitrogen, nitrogen is dissolved in all of our tissues. The amount
CSU LA - BIOL - 518
MICROBIOLOGY AND MOLECULAR BIOLOGY REVIEWS, Sept. 2004, p. 518537 1092-2172/04/$08.00 0 DOI: 10.1128/MMBR.68.3.518537.2004 Copyright 2004, American Society for Microbiology. All Rights Reserved.Vol. 68, No. 3Determination of the Core of a Minimal Bacter
Allan Hancock College - EE - 301
A PRIMER IN MATLABME C91 Fundamentals of Control Systems I Winter, 1996 J.E. ColgateMatlab is a very powerful application for performing all sorts of analyses on linear systems. For instance, Matlab can be used to solve for pole and zero locations, to s
Miami University - PHY - 182
Solutions to HW on Boltzmann distribution and Entropy1)2)4)As shown in class for a two-level system,5)6)7)8)9)
Oregon State University - CS - 589
Cognitive Walkthrough Mini-ProjectCS 589, Spring 2003(For teams of 3-4: in our experience, teams of 3 or morefind errors much better than smaller teams.)Pick a small aspect of a VPL or VPE you all have experience with oraccess to, and a goal.Possibl
Oregon State University - CS - 589
A Scalable Method for Deductive Generalization in the Spreadsheet Paradigm1Margaret Burnett*, Sherry Yang*, and Jay Summet* Oregon State University Corvallis, Oregon cfw_burnett, summet@cs.orst.edu* *Oregon Institute of Technology Klamath Falls, Oregon