473,385 Members | 1,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

cant find the prob!!HELP

hi can anyone help me with this prog. cant find the prob why it cant display

Expand|Select|Wrap|Line Numbers
  1.     cout<<"This is the display of your transaction"<<endl;
  2.  
  3.                 ifstream fobj;  //declare input file stream
  4.  
  5.                 fobj.open("trans.txt"); //open file
  6.  
  7.                 if(!fobj) //File not opened
  8.                 {
  9.                     cout<<"File cant open "<<endl;
  10.                     return 1;
  11.                 }
  12.  
  13.                 cout<<"<Date>"<<"\t\t<Name>"<<"\t<AccountNo>"<<"\t<AccountType>"<<"\t<TransType>"<<"\t<Amount>"<<endl;
  14.                 fobj>>timestamp>>name>>acc>>type>>trans>>amount;
  15.  
  16.                 while(fobj)
  17.                 {
  18.                     cout<<timestamp<<"\t"<<name<<"\t"<<acc<<"\t"<<type<<"\t\t"<<trans<<"\t\t"<<amount<<endl;
  19.  
  20.                     fobj>>timestamp>>name>>acc>>type>>trans>>amount;
  21.  
Expand|Select|Wrap|Line Numbers
  1. ofstream fobj;  //declare input file stream
  2.  
  3.     fobj.open("c:\\trans.txt",ios::app); //open file
  4.  
  5.  
  6.  
  7.         if(!fobj) //File not opened
  8.             {
  9.                 cout<<"File cant open "<<endl;
  10.                 return 1;
  11.             }
  12.  
  13.         else
  14.             {
  15.  
  16.                 fobj<<timestamp<<","<<name<<","<<acc<<","<<type<<","<<trans<<","<<amount<<endl;
  17.             }
  18.  
  19.  
  20.         fobj.close();  //close file
  21.  
i have created a file input but when i display it the output is not there what is the problem? when compiling it shows no error!!HELP!!

thanks in advance.
regrads
andrew
Feb 25 '07 #1
2 2049
horace1
1,510 Expert 1GB
it is not something as simple as a difference in file names? i.e. in current directory
Expand|Select|Wrap|Line Numbers
  1.         fobj.open("trans.txt"); //open file
  2.  
or in c:\
Expand|Select|Wrap|Line Numbers
  1.     fobj.open("c:\\trans.txt",ios::app); //open file
  2.  
Feb 25 '07 #2
it is not something as simple as a difference in file names? i.e. in current directory
Expand|Select|Wrap|Line Numbers
  1.         fobj.open("trans.txt"); //open file
  2.  
or in c:\
Expand|Select|Wrap|Line Numbers
  1.     fobj.open("c:\\trans.txt",ios::app); //open file
  2.  
thanks for ya reply but its still the same no input!!here is a new program i created but dun know where the prob is: can anyone help?
Expand|Select|Wrap|Line Numbers
  1. case 1:
  2.             {
  3.  
  4.                 cout<<"This is the display of your transaction"<<endl;
  5.  
  6.                 ifstream fobj;  //declare input file stream
  7.  
  8.                 fobj.open("c:\\trans.txt"); //open file
  9.  
  10.                 if(!fobj) //File not opened
  11.                 {
  12.                     cout<<"File cant open "<<endl;
  13.                     return 1;
  14.                 }
  15.  
  16.                 cout<<"<Date>"<<"\t\t<Name>"<<"\t<AccountNo>"<<"\t<AccountType>"<<"\t<TransType>"<<"\t<Amount>"<<endl;
  17.                 fobj>>timestamp>>name>>acc>>type>>trans>>amount;
  18.  
  19.                 while(fobj)
  20.                 {
  21.                     cout<<timestamp<<"\t"<<name<<"\t"<<acc<<"\t"<<type<<"\t\t"<<trans<<"\t\t"<<amount<<endl;
  22.  
  23.                     fobj>>timestamp>>name>>acc>>type>>trans>>amount;
  24.  
  25.  
  26.                 }
  27.                 fobj.close();//close file
  28.  
  29.                 cout<<"Do you wish to go back to main menu?(y/n)"<<endl;
  30.                 cin>>back;
  31.                 if(back == 'y' || back == 'Y')
  32.                 {
  33.                     goto menu;
  34.                 }
  35.                 else if ( back == 'n' || back == 'N')
  36.                 {
  37.                     goto case0;
  38.                 }
  39.  
  40.             }
Expand|Select|Wrap|Line Numbers
  1.     ofstream fobj;  //declare input file stream
  2.  
  3.     fobj.open("c:\\trans.txt",ios::app); //open file
  4.  
  5.  
  6.  
  7.         if(!fobj) //File not opened
  8.             {
  9.                 cout<<"File cant open "<<endl;
  10.                 return 1;
  11.             }
  12.  
  13.         else
  14.             {
  15.  
  16.                 fobj<<timestamp<<","<<name<<","<<acc<<","<<type<<","<<trans<<","<<amount<<endl;
  17.             }
  18.  
  19.  
  20.         fobj.close();  //close file
  21.  
  22.         }//whole switch case
  23.  
here is the problem when i put c:\\trans.txt in the first code it does not print the cout command after dat but when i take off the c:\\ it prints. why is it like this? and i still can show the file dat i stored in a file i created? why is it like this can anyone help me?

thanks in advance
Feb 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Daniel Bello Urizarri | last post by:
Hello: I have a web service that runs well on ASP 1.0. Now I'm migrating it to ASP 2.0, and now im at the point in wich the project runs under the ASP Developer server od the visual studio 2005,...
2
by: yasin | last post by:
I have to refresh my site every 5 secs but I cant find my sites meta tag in my site I think there is no meta tag clearly pages includes masterpages. How can I access the meta tag of my page whit...
1
by: Eric | last post by:
This program is running fine in my office i just copy it and run at home it start given that error and highlight Chr(13). I dont know is this is what the error is or some thing else Compiler...
1
by: niraj | last post by:
I am getting the following error /usr/bin/ld: cant find -lutl Please advice which module i need to install .I am unable to find it . TIA Niraj
1
by: foocc | last post by:
Hi, im trying to convert data reports (.dsr) in vb6 to crystal reports in vb.net. However, I cant seems to find it in my Microsoft Visual Studio 2005 Tools for Office. I've tried going to...
4
by: gawasthi | last post by:
Hi, I am absolutely new to perl and for a specific reqmt I am running the following script: #!/usr/bin/perl use warnings; use lib '/opt/InCharge65/IP/smarts/perl/5.6.1/lib'; use...
1
by: figaro | last post by:
Hi All, I have developed an application in .net, now the thing is I have to display the data on a report. I thought of using a crystal report. Here I understand that I have to add Crystal...
2
by: nevila | last post by:
i know my pass but i am a user and i cant find the ip of the camera at work?please help me?because i know the password. Best regard, Nevila
11
by: dowlingm815 | last post by:
the following code is generating an error; Mircosoft Access cant find the field '|" referred to in your expression" any suggestions would be appreciated. Private Sub...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.