changeSummary - The name of your text file should...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function changeSummary(st) % Consider the situation where you have given a text file to a friend to % review and make changes to. Your friend has found several lines that % need to be changed. Your friend kept up with which lines need to be % changed, and what they need to be changed to. % Given a structure array with fields "linenum" and "changeto", write a % function changeSummary that summarizes the changes to be made into a % text file (.txt). The field "linenum" contains the number of the line % that should be changed (as a double) and the field "changeto" contains % a string of what the line should be changed to. For simplicity's sake, % a new line must follow each new line you create, including the last % line. Notice your function does not have an output; it should only % create a text file on your working directory.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The name of your text % file should be "Changed_Summary.txt". You may assume no fields in the % structure array are empty. Do not use the 't' option with fopen. Be % sure that you follow our examples exactly- adding excessive whitespace % (spaces, tabs, newline characters) or getting case wrong will result in % a loss of credit. % Changed_Summary.txt should have a line of text for every structure in % the structure array, and should read like so: % Line # should be changed to "<some text>" %usage: changeSummary(st) fh = fopen('Changed_Summary.txt','w'); %opens the file and allows you to write into it for x = 1:length(st) %initial condition fprintf(fh,'Line %d should be changed to "%s"\n',st(x).linenum,st(x).changeto); %prints out the desired lines and their numbers end fclose(fh); %closes the file end...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Tech.

Ask a homework question - tutors are online