Author |
Message |
programming.noob
|
Posted: Sat Jun 10, 2006 11:22 am Post subject: 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*** |
|
|
|
|
|
Sponsor Sponsor
|
|
|
wtd
|
Posted: Sat Jun 10, 2006 11:27 am Post subject: (No subject) |
|
|
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
|
Posted: Sat Jun 10, 2006 11:18 pm Post subject: (No subject) |
|
|
yes im talking about standard output, sorry im new to the C language. |
|
|
|
|
|
programming.noob
|
Posted: Sat Jun 10, 2006 11:22 pm Post subject: (No subject) |
|
|
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
|
Posted: Sun Jun 11, 2006 7:09 am Post subject: (No subject) |
|
|
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
|
Posted: Sun Jun 11, 2006 2:59 pm Post subject: (No subject) |
|
|
do i use fprintf, or fgets to ouput the contents from the notepad file? |
|
|
|
|
|
wtd
|
Posted: Sun Jun 11, 2006 3:40 pm Post subject: (No subject) |
|
|
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
|
Posted: Sun Jun 11, 2006 10:05 pm Post subject: (No subject) |
|
|
welll i know i have to read the file in however i dont know how to output the notepad file contents. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
programming.noob
|
Posted: Sun Jun 11, 2006 10:07 pm Post subject: (No subject) |
|
|
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
|
Posted: Sun Jun 11, 2006 10:45 pm Post subject: (No subject) |
|
|
No no.
Break the problem down into simpler problems. At this stage of the game, we're not even concerned with the program. |
|
|
|
|
|
Martin
|
Posted: Mon Jun 12, 2006 2:48 am Post subject: (No subject) |
|
|
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
|
Posted: Mon Jun 12, 2006 12:07 pm Post subject: (No subject) |
|
|
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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
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<50;i++)
fgets (file,50,FILE);
fputs ("bankdatabase.txt",stdout);
fclose (pFile);
fflush (stdin);
getchar();
return 0;
} |
|
|
|
|
|
wtd
|
Posted: Mon Jun 12, 2006 12:13 pm Post subject: (No subject) |
|
|
Not to sound harsh, but do you have the first clue how C works? |
|
|
|
|
|
programming.noob
|
Posted: Mon Jun 12, 2006 4:22 pm Post subject: (No subject) |
|
|
i have a vague idea..could you explain what you mean. Also i believe thats why i would come here...for help? |
|
|
|
|
|
programming.noob
|
Posted: Mon Jun 12, 2006 4:24 pm Post subject: (No subject) |
|
|
can someone tell me how to fix the error in this program there is always a conflict bw datatypes |
|
|
|
|
|
|