file stream's visibility

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Atharvan!!!

    #1

    file stream's visibility

    first of all accept my apologies for bad English.
    (I am not a native English speaker)

    I am a 1st year B.Sc CS student.

    This is about file handling.
    I am writing a program to receive feedbacks from students about ther
    professors and then give a tabular output.
    This is for whole college.(Actual ly program was already written by my
    friend in Visual Basic-but I need to write it myself in the one and
    only one language I currently known-Java and Python study are
    progressing)

    In my program I used a file handle object as

    fstream data;

    in the global section.
    And I have many functions,and they are called each other within
    themselves.

    If both of them need the same file to work with.

    ie., One function is used to enter some details to the file (In my
    program it is a structer of professors-which contains details about
    professor).Anot her is used to verify that that particular professor is
    not in the list-to reduce redundancy.

    I call the first function and use the global fstream object data to
    open a file.

    data.open("prof essor.FBA",ios: :in|ios::out|io s::app|ios::bin ary);
    //FBA shorts for Feed Back Agent-this is what the name I gave it.
    //I think there is no problem for naming the file as *.FBA,Am I?

    then receive user input to the structure object which is also global
    then before adding it to the file,call the second function with the
    structure as argument.note that now file is not closed explicitly.In
    the second function too we need the above file "professor. FBA" to work
    with.
    Now my question is that whether I can use the file with the data
    object(which is connected to the file and I never closed it.)
    I am a little bit confused, because after the first function become
    out of scope the file may be automatically closed,I am not sure :-( .\
    Can you experienced people help me?

    I need clarification.
    I am using file because I don't know how to connect to mySQL or even
    access( I am not prefer it because I need my programs works on Linux
    too)
    Can you give me any reference to this matter( database connectivity)
    I am using Dev C++ and Visual C++ 6 and turbo c++. first two are used
    very often because I don't know GUI programming.
    And in Linux Anjuta IDE.

    Arun
    [
    Atharvan!!!
    {333}
    <a href="http://chintaadaara.bl ogspot.com">Chi ntaadaara</a>
    ]
Working...