
-----------------------------------
programming.noob
Sat Jun 10, 2006 11:22 am

I need help with file handling???
-----------------------------------
FILE *fptr;
int num;
    fptr=fopen ("bankdatabase.txt","r");     
    fscanf (fptr,"%d",&num);
    
    ***how do i output the file into the C++ window***

-----------------------------------
wtd
Sat Jun 10, 2006 11:27 am


-----------------------------------
You should be aware that this is C code that you're dealing with, rather than C++.

There is no "C++ window".  Are you talking about standard output?

-----------------------------------
programming.noob
Sat Jun 10, 2006 11:18 pm


-----------------------------------
yes im talking about standard output, sorry im new to the C language.

-----------------------------------
programming.noob
Sat Jun 10, 2006 11:22 pm


-----------------------------------
I dont think you are my personal google i just wanted to know how i woud go about outputting the contents of the file database.txt. Which function would be appropriate.

-----------------------------------
wtd
Sun Jun 11, 2006 7:09 am


-----------------------------------
That's my signature.  It gets attached to every message I post.  

That said, if you Google "c file handling" you will get a lot of very relevant pages.

-----------------------------------
programming.noob
Sun Jun 11, 2006 2:59 pm


-----------------------------------
do i use fprintf, or fgets to ouput the contents from the notepad file?

-----------------------------------
wtd
Sun Jun 11, 2006 3:40 pm


-----------------------------------
Don't think in terms of code specifics .  Think in terms of breaking the problem down.

You have the file open.  What's the next thing you have to do?

-----------------------------------
programming.noob
Sun Jun 11, 2006 10:05 pm


-----------------------------------
welll i know i have to read the file in however i dont know how to output the notepad file contents.

-----------------------------------
programming.noob
Sun Jun 11, 2006 10:07 pm


-----------------------------------
Also what do i break the program down into.. steps... but how i dont understand. I just want to output the contents of the notepad file. I thought it was a one liner.

-----------------------------------
wtd
Sun Jun 11, 2006 10:45 pm


-----------------------------------
No no.

Break the problem down into simpler problems.  At this stage of the game, we're not even concerned with the program.

-----------------------------------
Martin
Mon Jun 12, 2006 2:48 am


-----------------------------------
As in, think of the steps to do this without the programming part first. Don't worry about the code, just the method. Write it out as a list in plain English - ie.
1. First, we have to do this
2. Then, we do this.
...

-----------------------------------
programming.noob
Mon Jun 12, 2006 12:07 pm


-----------------------------------
Can somebody tell me what the problem is with the error : cannot convert FILE to char for arguement.

How come i cant get this to work it just wont work. I planned it out and everythgin

#include 
#include 
#include 
#include 
#include 

int main ()
{   
char file [50];

    FILE * pFile;
    pFile = fopen ("bankdatabase.txt","r");
    if (pFile==NULL){
        printf ("File read correctly but not displayed");
        abort();
    }
    
    for (int i=0;i