codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  fstream and char array  Jemy at 13:27 on Tuesday, September 06, 2005
 

hi,

i have to admit that i am quite new in c++. Nevertheless, the following confuses me really:

The function first() gets a lists of files from a directory returned from another function.
The function getText() should go through each file an extract a given part.
So far so good. But I just have to use an open statement in the function getText() and my list of files is cut to only 3 members instead of initialy 5.
Here the code for better understanding:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int first()
{
char **myFiles = listFiles();
for (int i=0; i < myClass::cnt; i++)
{
printf("FILE%i: -%s- \n", i, myFiles);
getText(myFiles);
}
return (1);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int getText(char *filename)
{
ifstream in;

in.open((string(DIRECTORY) + filename).c_str());
in.close();
return (0);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

output (without calling getText()):
FILE0: -file1-
FILE1: -file2-
FILE2: -file3-
FILE3: -file4-
FILE4: -file5-

output (calling getText() in function first)
FILE0: -file1-
FILE1: -file2-
FILE2: -file3-
FILE3: --
FILE4: --

There must be something very important I didn't get yet!!??
Can anybody help me?

thanx
jemy










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Why Use Method?
•  Re: Help with filesystem object & displaying in a table
•  Re: Genetic Algorithm Help
•  Re: How to make an investment calculator
•  Re: line breaks in GUI
•  Re: Graph in Gui...
•  Graph in Gui...
•  Re: Counting zero values in a string
•  Re: Help!


Recent Articles
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net
Creating CSS Buttons


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005