Arrays II - Arrays II C-Strings (Character Arrays...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Arrays II C-Strings (Character Arrays Terminated with null character (‘\0’) char studentName[26]; studentName = “Wayne Summers”; //illegal include <cstring> strcpy(s1, s2); strcmp(s1, s2); strlen(s) String Input cin >> name; cin.get(str, size+1); String Output cout << name; Specifying Input/Output Files at Execution Time The String Type and Input/Output Files strVar.c_str() used to convert String Type to c-string List Processing Searching Sorting Insert item Delete item Searching // RECEIVES: (list, length, item searched for) //RETURNS: location if found, -1 otherwise int seqSearch (const int list[], int listLength, int searchItem) { int loc; bool found; found = false; loc = 0; { if (list[loc] == searchItem) found = true;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
else loc++; } if (!found) loc = -1; return loc; } Sorting a List: Selection Sort void selectionSort (int list[], int length) { int index, smallestIndex, minIndex; for (index = 0; index < length -1; index++) {
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

Arrays II - Arrays II C-Strings (Character Arrays...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online