473,661 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ Help with displaying code from file

Hi,

I'm trying to display customer details on screen from a file using
functions.

The details are written to the file first then I display them on screen
after I search for the file.

My problem is this:

I'm trying to display the details individually using this function for
void display();

All the other code is written I just need to get this function to run.

=============== =============== =============== ==

void display()
{

char filename[15];
char in_char,ans;
int line;

do
{
clrscr();
cout<<"\nTo Display Contractor Details on the Screen";
cout<<"\nType the file name you want to see";
cout<<"\n\nEG. F:YOUR_FILE_NAM E.txt :";
cin>>filename;

infile.open(fil ename, ios::in);
if(!infile)
{
clrscr();
cout<<"\n\n**** That file does not exist****\n";
cout<<"Type F:\ and then up to eight letters for the file name,"
<<" then a dot and then three characters for the file type";
cout<<"\n\nEXAM PLE F:\THISFILE.TXT ";
cout<<"\n\nDo you want to QUIT (Y/N)";
cin>>ans;
ans=toupper(ans );
}

}while((!infile )&&(ans!='Y') );

while(infile.ge t(in_char))
if (line>20)
{

cout<<(in_char) ;
cout<<"\n\nThat is the screen full...\n"
<<"\npress any key to clear it and continue...";
getch();
clrscr();

}
infile.close();

return;
}

=============== =============== =============== ==

When I run this code it displays each character one at a time and not
the details.

The details are about 10 lines long and I need the program to say
"screen full" so that when I click continue the next set of details
comes up...

I been looking and trying everything for 3 hours now and I must be
missing something... can anyone point me in the right direction.

Thanks for your time.

Oct 25 '05 #1
1 1333
no*****@gmail.c om wrote:
Hi,

I'm trying to display customer details on screen from a file using
functions.

The details are written to the file first then I display them on screen
after I search for the file.

My problem is this:

I'm trying to display the details individually using this function for
void display();

All the other code is written I just need to get this function to run.

=============== =============== =============== ==

void display()
{

char filename[15];
char in_char,ans;
int line;

do
{
clrscr();
cout<<"\nTo Display Contractor Details on the Screen";
cout<<"\nType the file name you want to see";
cout<<"\n\nEG. F:YOUR_FILE_NAM E.txt :";
cin>>filename;

infile.open(fil ename, ios::in);
if(!infile)
{
clrscr();
cout<<"\n\n**** That file does not exist****\n";
cout<<"Type F:\ and then up to eight letters for the file name,"
<<" then a dot and then three characters for the file type";
cout<<"\n\nEXAM PLE F:\THISFILE.TXT ";
cout<<"\n\nDo you want to QUIT (Y/N)";
cin>>ans;
ans=toupper(ans );
}

}while((!infile )&&(ans!='Y') );

while(infile.ge t(in_char))
if (line>20)
{

cout<<(in_char) ;
cout<<"\n\nThat is the screen full...\n"
<<"\npress any key to clear it and continue...";
getch();
clrscr();

}
infile.close();

return;
}

=============== =============== =============== ==

When I run this code it displays each character one at a time and not
the details.

The details are about 10 lines long and I need the program to say
"screen full" so that when I click continue the next set of details
comes up...

I been looking and trying everything for 3 hours now and I must be
missing something... can anyone point me in the right direction.

Thanks for your time.


Look at your variable line. Where do you give it a value? Answer,
nowhere. How does you problem say you need to read the file? Answer,
line by line. How do you read the file? Answer, character by character.

I don't know what you mean when you say that you must be missing
something, the problem is that your code bears no relation to the
problem you are trying to solve.

Here's a better way

int line_count = 0;
while (read a line from file)
{
display line;
++line_count;
if (line_count%20 == 0)
display 'press any key to continue';
}

Something like that anyway, you can fill in the gaps.

john
Oct 25 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
6530
by: Axel | last post by:
Hiho, here my Newbie question (Win32 GUI): I'm reading a file in binary mode to a char* named buffer. I used malloc(filesize) to make the needed space avaiable. The filedata in the buffer seems to be ok..I can write the variable buffer back to a file and the contents is ok. So I think until here all goes fine... But now I want write the buffer contents to a Memo-Box for displaying.
2
2847
by: Joe Price | last post by:
Hi chaps I've got an XML file, within that file i've embedded html code using the <!]> tag I'm displaying that xml file through a browser using an xsl style sheet. However it is displaying any html from the xml file as text, ie its displaying as text <br/> and <b> etc
0
1572
by: Wynter | last post by:
RE: from Displaying a Document using the ASPNET user account to the Client Browser discussion (3/2/2004 Buddy Thanks for helping me on getting the document to display. But now I am left with a second issue. While I was displaying the document as an attachment I end up with an extra window open or if I remove the Target='_blank' then my main window goes blank What I am doing is using the base code from...
1
1957
by: Mark ??;-\) | last post by:
I would like to display a listing of files on a web page as follows: If there is only one file: display the section name and then display the current file. If there is more than one file (for the first page): display the section name, the current file and a few archive files. If there is more than a page full (for each additional page): display the section name, and the next set of archive files.
3
5466
by: Kidus Yared | last post by:
I am having a problem displaying Unicode characters on my Forms labels and buttons. After coding Button1.Text = unicode; where the unicode is a Unicode character or string (‘\u1234’ or “\u1234”) It seems to work the first time I set the button to the Unicode character. After a while, when saving my code, I get a pop-up window stating that I need to save the file as a Unicode else my changes will not be saved. Seance I do not want...
0
1724
by: Fronky | last post by:
Hope someone can help. I am still learning, so no laughing please. I am displaying records from a database using Response.Write(""); instead of the usual datagrid method. I am doing it this way to achieve the result I require. However. Since I have added a button to the screen, and have had to include the "object sender, System.EventArgs e", the Response.Write code has been appearing within the Documents_Table(null,null); tag on the...
1
1331
by: asad | last post by:
hello how ru all, i have some problem in displaying xml file in asp.net, i successfully create an xml file but when want to display it through ASP.NET code it throwing following error. Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 2, position 3.
12
2660
by: Patxi | last post by:
This is the first time I try to use cookies, and despite of reading some tutotials, I'm have real trouble to make it work correctly. My cookie reading code is in Master Page. When I click on a test button (in a WEb User Control inside the aspx page), cookie value is displayed in Master Page but if I go to another page, no value is displayed... I need to be able tu use cookie's value across all the site... What am I doing wrong ? Code...
5
2372
by: dav3 | last post by:
I am by no means an ultra slick programmer and my problem solving skills.. well they leave much to be desired. That being said I have been working on the following problem for the past few days and have yet to find a solution. My program is supposed to read in a txt file which contains 2 lines of numbers. Program reads the file and stores each line as a string, then converts each character to an integer. Once char is converted to an int the...
2
2183
by: peteinglastonbury | last post by:
I'd be most grateful if someone would help me. I hope I'm in the right forum (apologies if not) - I'm not sure whether my problem is CGI or Javascript related. I found a script called BatmoAudiopop.js which opens a pop-up browser window with an audio player when a link is clicked. Basically, it sets the right mime-type depending on the operating system and audio file type, then opens a window with the audio file (passed as a parameter) in...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8754
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8542
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.