Reading Pointers: Chapter 4, pages 144 - 172. Strings as Arrays of Characters string Greeting = "hello"; vs. char *Greeting = "hello";

Slides:



Advertisements
Similar presentations
Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all.
Advertisements

In Pictures The Gettysburg Address Photo by Tim EvansonTim Evanson.
What should be done with 7,000+ deceased soldiers after a battle?
American History Museum Walkthrough. Bombing of Fort McHenry during the War of 1812.
1861 – 1865 Timeline & Photo Presentation
Community Project Presentation Tips and Content Guide.
Gettysburg Address Four score and seven years ago, our fathers brought forth upon this continent a new nation: conceived in liberty, and dedicated to the.
A new way of looking at texts
Microsoft PowerPoint The Bells and Whistles.
The Gettysburg Address Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated.
The Battle of Gettysburg The Turning Point of the War.
Richardson 3040 PowerPoint Rules Rule 1 Everything should enhance the content of the presentation Regions of Tennessee.
The Civil War Southern Secession A. Lincoln elected President in Southerners – viewed struggle over slavery as a conflict between the.
Plagiarism: what it means to you Ms. Allen JTA Library Media Specialist.
Basics: Text boxes Backgrounds Shapes Fonts Transitions Animations Spell check Clip Organizer Advanced: Music Video / URL Merge Presentations Narration/voice.
By Karissa Lynn Montag The Lincoln Museum is Located in Springfield Illinois. In one room there is Lincoln’s house and you can dress up as Lincoln or.
Improving Your Communication Skills & Speaking in Turbulent Situations.
LINCOLN’S GETTYSBURG ADDRESS Lincoln gave the battle a higher meaning. The war has a purpose. These men died to make Americans live up to their own beliefs-
LINCOLN’S GETTYSBURG ADDRESS November 19, To understand what Abraham Lincoln was stating in the Gettysburg Address.
The Call For Change Supplemental Information 20. MCS Intervention Strategy Repeated Reading Readers’ Theater 1. Choose a script. Choose a prepared script,
Visual Aids Communication delivered over multiple channels is more efficient than communication over a single channel –More likely the whole message.
15,000 spectators were in attendance The Gettysburg Address.
Gettysburg Project
*701 *702 Graduate Seminar Useful Tips Host: JJ Hoyt.
World Affairs 9/7/11 Legacy of Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and.
The Turning Point Chapter 9 Section 4 The Battle Of Vicksburg The battle of Vicksburg lasted from May July1864.
15,000 spectators were in attendance The Gettysburg Address.
Lincoln’s Gettysburg Address Given November 19, 1863 on the battlefield near Gettysburg, Pennsylvania, U.S.A.
Battle Hymn for Gettysburg Music adapted/arr. by Teresa Jennings Music K-8, Vol.19, Num.3 © 2009 Plank Road Publishing, Inc. All Rights Reserved- used.
Civil War, pt3. Andersonville Prison Libby Prison.
Quiz Question What is it that is “equivalent” in the equivalence principle of general relativity? A.Light and matter B.Light and energy C.Velocity and.
President for a day Can you handle it???. Your Task… You are being asked to dedicate a cemetery for fallen soldiers. The cemetery is on the site where.
Abraham Lincoln He was born on February 12, 1809 in Hodgenville Kentucky. He is the 16 th President of the United States of America He was in office from.
Last lecture: Point Estimation A point estimator is function of the observations in a random sample which is used to estimate an unknown parameter. A point.
ENGLISH LANGUAGE ARTS GRADE 9 Mrs. Jeffries. Parallelism Unit 1 PARALLEL STRUCTURE means using the same pattern of words to show that two or more ideas.
Gettysburg Key turning point in the war. Gettysburg Address "It is the desire that, after the Oration, you, as Chief Executive of the nation, formally.
“EVERY SPEECH IS A RHYMELESS, METERLESS VERSE.” -WINSTON CHURCHILL Power Poetry.
1/9/14 O CO: Evaluate Lincoln’s efforts to abolish slavery and to end the Civil War. O QW: O Read and analyze the quotes from Lincoln’s letters.
The Civil War Antietam Gettysburg. What does Secession mean? What was Fort Sumter? Who took control of it? Who was the confederate commander at the Battle.
The Gettysburg Address By Zoe and Bryony. Information Abraham Lincoln wrote and read the famous speech It was spoken at the dedication of the soldiers'
Gettysburg Picture Analysis- Gallery Walk Civil War Picture Analysis- With a partner- Use post-it notes to analyze and annotate the photos. Put the post-its.
People Cannot Choose a Representative Sample Carla L. Hill Marist College.
% The percent sign is computer language for: Get ready, here comes something you want or OK that is all you needed A “%” should be at the beginning and.
Computer Skills and Applications 8th Grade
Presentation Purpose 6.01 Understand business uses of presentation software and methods of distribution Presentation Purpose.
The Battle of Gettysburg
Did Lincoln free the slaves? Or did the slaves free themselves?
Civil Religion in the American Context
warm-up: Complete on your own sheet of paper.
Raise your hand if… you have ever read an entire paragraph, passage, or page only to realize that you have absolutely no clue what you just read.
Civil War.
Raise your hand if… you have ever read an entire paragraph, passage, or page only to realize that you have absolutely no clue what you just read.
VUS.7c The Civil War The Emancipation Proclamation and the principles outlined in Lincoln’s Gettysburg Address.
Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all.
7X Tuesday Gettysburg to Appomattox
Gettysburg Picture Analysis- Gallery Walk
The Gettysburg Address
Raise your hand if… you have ever read an entire paragraph, passage, or page only to realize that you have absolutely NO clue what you just read.
Presentation Purpose 6.01 Understand business uses of presentation software and methods of distribution Presentation Purpose.
The Gettysburg Address
Raise your hand if… you have ever read an entire paragraph, passage, or page only to realize that you have absolutely no clue what you just read.
SOAPSTone is a reading and writing strategy that helps us recognize the structure of a text and aides student writing from planning through to revision.
7X Monday The Tide of War Turns
Bell Ringer Write a short response to the following quote. I am looking for about 4 sentences total. Tell me what you think the quote means and how it.
Rhetorical Devices…SPEECHES!
Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all.
8X Thursday Gettysburg to Appomattox
Emancipation Proclamation
Lincoln's 2nd Inaugural What works about this speech?
Presentation transcript:

Reading Pointers: Chapter 4, pages

Strings as Arrays of Characters string Greeting = "hello"; vs. char *Greeting = "hello";

pointers imagine passing the following string to a function: void printStr( string x ); x = "Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation, so conceived and so dedicated, can long endure. We are met on a great battle- field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate— we can not consecrate—we can not hallow—this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us — that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion — that we here highly resolve that these dead shall not have died in vain — that this nation, under God, shall have a new birth of freedom — and that government of the people, by the people, for the people, shall not perish from the earth." printStr( x );

in computer memory fourscoreandsevenyearsagoour ……… shallnotperishfromtheearth.0

computer memory is ADDRESSED 100four 104score 109and 112seven 117years addressdata

a shortcut we could pass our huge string "x" to any function simply by passing the address of the first character. the address of the first character is referenced like this: " *x ". If x is defined as *x the x is a pointer to a string of characters.

value vs. reference a string defined as: string x = "hello"; is passed around and used as a complete value. a string defined as: char *x = "hello"; is passed around and used as a reference, or pointer, to a string. much quicker

note:&x &x refers to the actual address in memory of x… in our example, &x = 100; if a function expects a pointer, and all you have is a variable, sometimes you can send the address and it won't complain why? because a pointer IS an address.

we will use references where appropriate strcmp, strcpy, strcat library functions only take pointers as arguments char *x = "hawk"; char *y = "eagle"; strcmp( x, y ) yields a 3…. why/ - if hawk comes before eagle (it doesn't) 0 if they're identical strings (they're not) + if hawk comes after eagle (it does)

let's alphabetize a list … this may take a while… const int arraySize = 8; char *birds[ arraySize ] = { "eagles", "hawks", "bluejays", "robins", "cardinals", "owls", "doves", "ducks" };

our menu of choices

we'll need to print the list the call from main:

Why is printAnyArray passed an array, rather than just using the global birds[ ] array? - it is more useful then, because it can print any array, not just birds[ ] birds is defined as a pointer a pointer to an array is expected

we'll need to swap around array elements

finally, the bubble-sort, in main

strings vs. char pointers when you define a string: string userInput; you cannot deal with individual characters…. but when you define a pointer to the first character of a string: char *userInput; it becomes a character array, and you can deal with it in BOTH ways

strlen char *p = "This is a whole sentence."; int length = strlen( p ); cout << p << " is " << length << " characters long "; for (x=0; x<result4; x++) { // find the spaces if ( p[x] == ' ') { cout << x << " "; // will list the spaces } }

tell if a string contains only digits char *q = " "; bool containsLetters = false; for (x=0; x<rstrlen(q); x++) { if ( (q[x] != '0') && (q[x] != '1') && (q[x] != '2') && (q[x] != '3') && (q[x] != '4') && (q[x] != '5') && (q[x] != '6') && (q[x] != '7') && (q[x] != '8') && (q[x] != '9') ) { containsLetters = true; } } // end for

convert strings to char* // our first member function: string userInput; cout << "Enter a string: "; cin >> userInput; const char *q = userInput.c_str( ); // you can now use q in strlen and strcmp

member function? #include string userInput; const char *p = userInput.c_str( ); the authors of the string library provided a way to get the pointer value of any string, to be used when converting a string to a character pointer, for use in strcmp and strlen