Write a function named read_line

Assignment Help C/C++ Programming
Reference no: EM13713074

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

Reference no: EM13713074

Questions Cloud

Prepare a general set of instructions : Prepare a general set of instructions that will allow us to change any displayed value (from 0 to 9) to any desired value (from 0 to 9) in the least number of steps.
Implement a class student : Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply a suitable constructor and methods getName( ), addQuiz(int score), getTotalScore( ), and getAverageScore ( ).
Write a flowchart to solve any linear equation : Write a flowchart to solve any linear equation ax+b=0 -
Find how much heat per cycle does the engine absorb : How much work does this engine do each cycle.How much heat per cycle does this engine absorb at the hot reservoir?
Write a function named read_line : 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'.
What should be the banking angle of the curve : What should be the banking angle of the curve so that the force of the pavement on the tires of the car is in the normal direction? Answer in units of degrees.
What is the average friction on the ball : a 200 g plastic ball is at rest on a frictionless incline 0.658 m above the surface of a table. The ball then rolls down the incline and across the table coming to rest after a distance of 2.45 m.
Determine how far apart are mars and phobos : Mars has a mass of about 6.77×1023kg, and its moon Phobos has a mass of about 9.6×1015kg. If the magnitude of the gravitational force between the two bodies is 4.58×1015N.
Write an unambiguous grammar : Write an unambiguous grammar for the given languages- You have to prepare unambiguous grammar for the above languages. Please help! I am stuck on this question

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd