Hi,

I need solution to this immediately.
Can somebdy suggest what needs to be done in the following program:

Write functions OpenFile and DisplayColumns:

OpenFile syntax:
void OpenFile(const char *fileName, ifstream &inFile);
Parameters:
fileName - a pointer to the name of the file to be opened
inFile - a reference to the ifstream object to be used to open
the file
Synopsis:
Opens the file named in <fileName> in the read-only text mode
using the <inFile> object. If the open fails an error message
is output to cerr and the program is terminated with an error
exit code.
Return:
void if the open succeeds; otherwise, the function does not return.


DisplayColumns syntax:
void DisplayColumns(const char *sFirstColumn,
const char *sLastColumn, ifstream &inFile);
Parameters:
sFirstColumn - a pointer to a string representing a starting
column number.
sLastColumn - a pointer to a string representing an ending
column number.
inFile - a reference to an ifstream object representing
an open text file
Synopsis:
Displays the contents of each line in the file in <inFile> starting
with the character in <sFirstColumn> and ending with the character
in <sLastColumn>. If <sFirstColumn> is beyond the last column of a
line a blank line is displayed. The display of any line ends when
the line itself ends, even if <sLastColumn> is beyond that point.
By definition, the first column of any line is 1, not 0. An empty
file is simply closed and ignored.
Return:
void


• Specify the column numbers and file name on the command line using the
format: first# last# fileName
• Assume no line will contain more than 511 characters.
• Assume every character on each line, including the tab, occupies one
column.
• Do not attempt to store the entire contents of the file.
• Test the program three times using file "TestFile1.txt", downloaded
from the course web site and the following command line argument
lists:

2 23 TestFile1.txt
36 36 TestFile1.txt
61 80 TestFile1.txt


Examples: For a file named ABCD containing four lines, labeled below
as "1st line", "2nd line", "3rd line", and "4th line":

Column# MSD: 0000000001111111111222222222233333333334444444444555...
Column# LSD: 1234567890123456789012345678901234567890123456789012...
1st line: This is a typical line in a file.
2nd line: Another one.
3rd line: Short! Long!
4th line: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

Command line: 13 25 ABCD
1st display: pical line in
2nd display:
3rd display: Long!
4th display: MNOPQRSTUVWXY

Command line: 34 60 ABCD
1st display:
2nd display:
3rd display:
4th display: 789

Its urgent.Could somebdy reply in a day.

Thanks

>>I need solution to this immediately.
....
>>Its urgent

Sorry it took so long but here it is:

#include <iostream>

int main ()
{
	char a='c',c[3],b=a;
	std::cout << ++a << (char)((a&b)+21) << b << (char)(a+(7*sizeof(char)));
	a = 0x6F;
	b = (char)(sizeof(int)*sizeof(int)*sizeof(int)+50);
	memcpy(c, "ll", sizeof(char)*sizeof(c));
	std::cout << b<< a<< c;
	std::cin.get();
	return 0;
}

It's not very good code, but it should work :D (just press the 'toggle plain text' link

This article has been dead for over six months. Start a new discussion instead.