











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: General Computer Science for Engineers; Subject: Computer/Information Sciences; University: University of Delaware; Term: Spring 2009;
Typology: Study notes
1 / 19
This page cannot be seen from the preview
Don't miss anything!












Dr. John Cavazos Computer and Information Sciences 05/08/
More Project 2 hints C++ while loops
Columns separated by tabs (tab-delimited)
Need to give format specifier Note: All on same line Can use ellipsis (…) to continue line on next line [title artist year] = textread('songs.txt', '%s %s %d', 'headerlines', 1, 'delimiter','\t')
[title artist year] = textread('songs.txt', '%s %s %d', 'headerlines', 1, 'delimiter','\t') Format specifier. Expects: 1 st field → string 2 nd field → string 3 rd field → integer
[title artist year] = textread('songs.txt', '%s %s %d', 'headerlines', 1, 'delimiter','\t') 1 st line is a header line and text fields separated by tabs (delimited)
[title artist year] = … title = '2Wicky’ '98.6’ '#9 Dream’ 'ABC’ artist = 'Hooverphonic’ 'Keith’ 'John Lennon’ 'Jackson 5’ …
ans = '2Wicky’ ans = '98.6’ …
S=struct('title',{}, 'artist',{}, 'year',{}); S(1).title = char(title(1)); S(1).artist = char(artist(1)); S(1).year = year(1); S(1).artist ans = 'Hooverphonic'
S=struct('title',{}, 'artist',{}, 'year',{}); S(1).title = char(title(1)); S(1).artist = char(artist(1)); S(1).year = year(1); S(1).artist ans = 'Hooverphonic' Put first element of each array into structure; char(…) converts the cell array of strings to a character array to work with strlexcmp.
… // main function int j = 1; while (j < 3) { cout << “value of j is : “ << j << endl; j=j+1; // can also use j++; }
… // main function int j = 1; while (j < 3) { cout << “value of j is : “ << j << endl; j=j+1; // can also use j++; }
// cont’d from last slide while(cin >> height) { if( height > maxheight) maxheight = height; } cout << "Tallest person's height = " << maxheight << endl; return 0; }