Supposes you have a directory whose name is stored in


Answer the following questions and also justify your answers with appropriate examples

Question- 1 Write a function named 'read_line' which has one input parameter ('specs') and one output parameter ('ret_line'). Your function should do the following:

Question- 2 Suppose 'specs' is a struct with 4 fields: {file_dir, file_name, nlines, my_line}. Use if?end or if?elseif?end statements to check that:

Part a- 'specs'isindeedastruct.

Part b- Thefourfieldsaboveallexist.

Part c- Thefields'file_dir','file_name'are(non?empty)strings

Question-3 You should use the 'error' function to indicate an error if your checks above fail.

Question-4 Now supposes you have a directory whose name is stored in 'specs.file_dir' which contains a file whose name is stored in 'specs.file_name'.

You should suppose that you have a simple text file which contains text (NOT numeric data).

Question-5 Your function should open the file (hint: use fopen), and read 'specs.nlines' number of lines (rows) from the file into a cell array 'C'. Each element of C should have one line from your file.

You can suppose that there are no errors in the parameter 'specs.nlines', that is, it can't exceed the number of lines in your file.

Question-6 Suppose 'specs.my_line' specifies some line number. The output parameter 'ret_line' should be set to this line (you should return a string).

Question-7 Verify that your code works by saving some text into a file (created in notepad / textedit) and saving the file with extension '.txt'. You should attach the file (call it 'test.txt') with your code.

Could you show me how to write a proper code for this problem and how to complete it. Thanks

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Supposes you have a directory whose name is stored in
Reference No:- TGS0966331

Expected delivery within 24 Hours