hey guys,
i have a task which involves being given a source code and printing out the LOC in each object and each method along with total LOC in file and number of methods
i am racking my brain on how to detect an object or method
any ideas???
also i am having another problem
i open a text file using the ifstream, and read the lines from that file
these lines are the names of other files, once EOF is reached i close the open file
i then want to use ifstream again to open one of the files mentioned in the file that was just open, but this isnt seeming to work
here is some pseudocode to illustrate what i mean
ifstream = infile;
infile.open("file containing other file names")
// store filenames in linked list
if(EOF)
infile.close()
//go thru linked list one at a time
ifstream.open(linkedlist->data) <---- this line doesnt seem to work
The most important thing for opening a file is that the filename is of type
const char *
in the example you can see how you cast from string to char * and from char * to const char *.
I created a vector called linked_list in which all the filenames of the input file get stored.
after that I open all the files from this list one by one and put them in the infiles struct that I declared. In here as well the filenames as the retrieved strings from those files get stored.
finally I have a function that diplays everything thats loaded in memory.
also something I just found out is that when you open and close an fstream object, and after that you open it again, that it's needed to force the filepointer back to the begin of the file (or whatever point you want it) If you don't, file.eof() might return true for a file that has just been opened.
hey ronnie
thank you very much
i believe this line file.seekg (0, ios::beg);
is what wasn't working for me, because it was always detecting a EOF in every file apart from the first
appreciate it alot!!!
regards chris